home *** CD-ROM | disk | FTP | other *** search
/ Windows Expert / Windows Expert.iso / windownt / awksrc.zip / AWKTAB.C < prev    next >
C/C++ Source or Header  |  1993-09-28  |  106KB  |  3,238 lines

  1.  
  2. /*  A Bison parser, made from awk.y  */
  3.  
  4. #define YYBISON 1  /* Identify Bison output.  */
  5.  
  6. #define    FUNC_CALL    258
  7. #define    NAME    259
  8. #define    REGEXP    260
  9. #define    ERROR    261
  10. #define    YNUMBER    262
  11. #define    YSTRING    263
  12. #define    RELOP    264
  13. #define    APPEND_OP    265
  14. #define    ASSIGNOP    266
  15. #define    MATCHOP    267
  16. #define    NEWLINE    268
  17. #define    CONCAT_OP    269
  18. #define    LEX_BEGIN    270
  19. #define    LEX_END    271
  20. #define    LEX_IF    272
  21. #define    LEX_ELSE    273
  22. #define    LEX_RETURN    274
  23. #define    LEX_DELETE    275
  24. #define    LEX_WHILE    276
  25. #define    LEX_DO    277
  26. #define    LEX_FOR    278
  27. #define    LEX_BREAK    279
  28. #define    LEX_CONTINUE    280
  29. #define    LEX_PRINT    281
  30. #define    LEX_PRINTF    282
  31. #define    LEX_NEXT    283
  32. #define    LEX_EXIT    284
  33. #define    LEX_FUNCTION    285
  34. #define    LEX_GETLINE    286
  35. #define    LEX_IN    287
  36. #define    LEX_AND    288
  37. #define    LEX_OR    289
  38. #define    INCREMENT    290
  39. #define    DECREMENT    291
  40. #define    LEX_BUILTIN    292
  41. #define    LEX_LENGTH    293
  42. #define    UNARY    294
  43.  
  44. #line 26 "awk.y"
  45.  
  46. #ifdef DEBUG
  47. #define YYDEBUG 12
  48. #endif
  49.  
  50. #define    YYMAXDEPTH    300
  51. #define    YYSSIZE    YYMAXDEPTH
  52.  
  53. #include "awk.h"
  54.  
  55. static void yyerror (); /* va_alist */
  56. static char *get_src_buf P((void));
  57. static int yylex P((void));
  58. static NODE *node_common P((NODETYPE op));
  59. static NODE *snode P((NODE *subn, NODETYPE op, int sindex));
  60. static NODE *mkrangenode P((NODE *cpair));
  61. static NODE *make_for_loop P((NODE *init, NODE *cond, NODE *incr));
  62. static NODE *append_right P((NODE *list, NODE *new));
  63. static void func_install P((NODE *params, NODE *def));
  64. static void pop_var P((NODE *np, int freeit));
  65. static void pop_params P((NODE *params));
  66. static NODE *make_param P((char *name));
  67. static NODE *mk_rexp P((NODE *exp));
  68.  
  69. static int want_assign;        /* lexical scanning kludge */
  70. static int want_regexp;        /* lexical scanning kludge */
  71. static int can_return;        /* lexical scanning kludge */
  72. static int io_allowed = 1;    /* lexical scanning kludge */
  73. static char *lexptr;        /* pointer to next char during parsing */
  74. static char *lexend;
  75. static char *lexptr_begin;    /* keep track of where we were for error msgs */
  76. static char *lexeme;        /* beginning of lexeme for debugging */
  77. static char *thisline = NULL;
  78. #define YYDEBUG_LEXER_TEXT (lexeme)
  79. static int param_counter;
  80. static char *tokstart = NULL;
  81. static char *token = NULL;
  82. static char *tokend;
  83.  
  84. NODE *variables[HASHSIZE];
  85.  
  86. extern char *source;
  87. extern int sourceline;
  88. extern char *cmdline_src;
  89. extern char **srcfiles;
  90. extern int errcount;
  91. extern NODE *begin_block;
  92. extern NODE *end_block;
  93.  
  94. #line 76 "awk.y"
  95. typedef union {
  96.     long lval;
  97.     AWKNUM fval;
  98.     NODE *nodeval;
  99.     NODETYPE nodetypeval;
  100.     char *sval;
  101.     NODE *(*ptrval)();
  102. } YYSTYPE;
  103.  
  104. #ifndef YYLTYPE
  105. typedef
  106.   struct yyltype
  107.     {
  108.       int timestamp;
  109.       int first_line;
  110.       int first_column;
  111.       int last_line;
  112.       int last_column;
  113.       char *text;
  114.    }
  115.   yyltype;
  116.  
  117. #define YYLTYPE yyltype
  118. #endif
  119.  
  120. #include <stdio.h>
  121.  
  122. #ifndef __STDC__
  123. #define const
  124. #endif
  125.  
  126.  
  127.  
  128. #define    YYFINAL        308
  129. #define    YYFLAG        -32768
  130. #define    YYNTBASE    61
  131.  
  132. #define YYTRANSLATE(x) ((unsigned)(x) <= 294 ? yytranslate[x] : 108)
  133.  
  134. static const char yytranslate[] = {     0,
  135.      2,     2,     2,     2,     2,     2,     2,     2,     2,     2,
  136.      2,     2,     2,     2,     2,     2,     2,     2,     2,     2,
  137.      2,     2,     2,     2,     2,     2,     2,     2,     2,     2,
  138.      2,     2,    49,     2,     2,    52,    48,     2,     2,    53,
  139.     54,    46,    44,    60,    45,     2,    47,     2,     2,     2,
  140.      2,     2,     2,     2,     2,     2,     2,    40,    59,    41,
  141.      2,    42,    39,     2,     2,     2,     2,     2,     2,     2,
  142.      2,     2,     2,     2,     2,     2,     2,     2,     2,     2,
  143.      2,     2,     2,     2,     2,     2,     2,     2,     2,     2,
  144.     55,     2,    56,    51,     2,     2,     2,     2,     2,     2,
  145.      2,     2,     2,     2,     2,     2,     2,     2,     2,     2,
  146.      2,     2,     2,     2,     2,     2,     2,     2,     2,     2,
  147.      2,     2,    57,    43,    58,     2,     2,     2,     2,     2,
  148.      2,     2,     2,     2,     2,     2,     2,     2,     2,     2,
  149.      2,     2,     2,     2,     2,     2,     2,     2,     2,     2,
  150.      2,     2,     2,     2,     2,     2,     2,     2,     2,     2,
  151.      2,     2,     2,     2,     2,     2,     2,     2,     2,     2,
  152.      2,     2,     2,     2,     2,     2,     2,     2,     2,     2,
  153.      2,     2,     2,     2,     2,     2,     2,     2,     2,     2,
  154.      2,     2,     2,     2,     2,     2,     2,     2,     2,     2,
  155.      2,     2,     2,     2,     2,     2,     2,     2,     2,     2,
  156.      2,     2,     2,     2,     2,     2,     2,     2,     2,     2,
  157.      2,     2,     2,     2,     2,     2,     2,     2,     2,     2,
  158.      2,     2,     2,     2,     2,     2,     2,     2,     2,     2,
  159.      2,     2,     2,     2,     2,     2,     2,     2,     2,     2,
  160.      2,     2,     2,     2,     2,     1,     2,     3,     4,     5,
  161.      6,     7,     8,     9,    10,    11,    12,    13,    14,    15,
  162.     16,    17,    18,    19,    20,    21,    22,    23,    24,    25,
  163.     26,    27,    28,    29,    30,    31,    32,    33,    34,    35,
  164.     36,    37,    38,    50
  165. };
  166.  
  167. static const short yyprhs[] = {     0,
  168.      0,     4,     6,     9,    11,    14,    15,    19,    20,    24,
  169.     27,    30,    33,    35,    38,    41,    43,    45,    47,    49,
  170.     51,    52,    60,    65,    67,    71,    72,    77,    83,    88,
  171.     90,    93,    95,    98,   100,   103,   106,   109,   113,   115,
  172.    122,   131,   140,   151,   161,   164,   167,   174,   179,   183,
  173.    187,   188,   193,   200,   203,   205,   207,   214,   224,   226,
  174.    229,   230,   232,   233,   236,   237,   240,   243,   246,   247,
  175.    249,   251,   255,   257,   260,   264,   265,   267,   268,   270,
  176.    272,   276,   278,   281,   285,   289,   290,   292,   294,   298,
  177.    300,   303,   307,   311,   312,   317,   323,   328,   332,   336,
  178.    340,   344,   346,   349,   353,   357,   361,   365,   371,   373,
  179.    376,   377,   382,   386,   390,   394,   396,   399,   403,   407,
  180.    411,   417,   419,   422,   424,   426,   430,   434,   438,   442,
  181.    446,   450,   453,   457,   458,   464,   469,   471,   476,   479,
  182.    482,   484,   486,   489,   492,   495,   498,   500,   501,   503,
  183.    505,   510,   513,   516,   519,   522,   524,   525,   527,   529
  184. };
  185.  
  186. static const short yyrhs[] = {    82,
  187.     62,    82,     0,    63,     0,    62,    63,     0,     1,     0,
  188.     62,     1,     0,     0,    15,    64,    74,     0,     0,    16,
  189.     65,    74,     0,    15,    76,     0,    16,    76,     0,    71,
  190.     74,     0,    74,     0,    71,    76,     0,    68,    70,     0,
  191.      4,     0,     3,     0,    67,     0,    37,     0,    38,     0,
  192.      0,    30,    69,    66,    53,    85,   104,    82,     0,   102,
  193.     75,   103,   105,     0,    92,     0,    92,   107,    92,     0,
  194.      0,    47,    73,     5,    47,     0,   102,    75,   103,   105,
  195.     82,     0,   102,   103,   105,    82,     0,    77,     0,    75,
  196.     77,     0,     1,     0,    75,     1,     0,    81,     0,   106,
  197.     82,     0,   106,    82,     0,   102,   103,     0,   102,    75,
  198.    103,     0,    80,     0,    21,    53,    92,   104,    82,    77,
  199.      0,    22,    82,    77,    21,    53,    92,   104,    82,     0,
  200.     23,    53,     4,    32,     4,   104,    82,    77,     0,    23,
  201.     53,    87,   106,    92,   106,    87,   104,    82,    77,     0,
  202.     23,    53,    87,   106,   106,    87,   104,    82,    77,     0,
  203.     24,    76,     0,    25,    76,     0,    79,    53,    91,   104,
  204.     84,    76,     0,    79,    88,    84,    76,     0,    28,    87,
  205.     76,     0,    29,    87,    76,     0,     0,    19,    78,    87,
  206.     76,     0,    20,     4,    55,    91,    56,    76,     0,    92,
  207.     76,     0,    26,     0,    27,     0,    17,    53,    92,   104,
  208.     82,    77,     0,    17,    53,    92,   104,    82,    77,    18,
  209.     82,    77,     0,    13,     0,    81,    13,     0,     0,    81,
  210.      0,     0,    41,    96,     0,     0,    42,    92,     0,    10,
  211.     92,     0,    43,    92,     0,     0,    86,     0,     4,     0,
  212.     86,   107,     4,     0,     1,     0,    86,     1,     0,    86,
  213.    107,     1,     0,     0,    92,     0,     0,    89,     0,    94,
  214.      0,    89,   107,    94,     0,     1,     0,    89,     1,     0,
  215.     89,     1,    94,     0,    89,   107,     1,     0,     0,    91,
  216.      0,    92,     0,    91,   107,    92,     0,     1,     0,    91,
  217.      1,     0,    91,     1,    92,     0,    91,   107,     1,     0,
  218.      0,   101,    11,    93,    92,     0,    53,    91,   104,    32,
  219.      4,     0,    92,    43,    31,   100,     0,    31,   100,    83,
  220.      0,    92,    33,    92,     0,    92,    34,    92,     0,    92,
  221.     12,    92,     0,    72,     0,    49,    72,     0,    92,    32,
  222.      4,     0,    92,     9,    92,     0,    92,    41,    92,     0,
  223.     92,    42,    92,     0,    92,    39,    92,    40,    92,     0,
  224.     96,     0,    92,    92,     0,     0,   101,    11,    95,    94,
  225.      0,    94,    33,    94,     0,    94,    34,    94,     0,    31,
  226.    100,    83,     0,    72,     0,    49,    72,     0,    94,    12,
  227.     94,     0,    94,    32,     4,     0,    94,     9,    94,     0,
  228.     94,    39,    94,    40,    94,     0,    96,     0,    94,    94,
  229.      0,    97,     0,    99,     0,    96,    51,    96,     0,    96,
  230.     46,    96,     0,    96,    47,    96,     0,    96,    48,    96,
  231.      0,    96,    44,    96,     0,    96,    45,    96,     0,    49,
  232.     96,     0,    53,    92,   104,     0,     0,    37,    98,    53,
  233.     90,   104,     0,    38,    53,    90,   104,     0,    38,     0,
  234.      3,    53,    90,   104,     0,    35,   101,     0,    36,   101,
  235.      0,     7,     0,     8,     0,    45,    96,     0,    44,    96,
  236.      0,   101,    35,     0,   101,    36,     0,   101,     0,     0,
  237.    101,     0,     4,     0,     4,    55,    91,    56,     0,    52,
  238.     97,     0,    52,   101,     0,    57,    82,     0,    58,    82,
  239.      0,    54,     0,     0,   106,     0,    59,     0,    60,    82,
  240.      0
  241. };
  242.  
  243. #if YYDEBUG != 0
  244. static const short yyrline[] = { 0,
  245.    136,   141,   149,   165,   166,   170,   172,   186,   188,   202,
  246.    208,   214,   216,   218,   231,   240,   242,   244,   254,   255,
  247.    259,   263,   271,   280,   282,   291,   293,   309,   311,   316,
  248.    318,   326,   328,   333,   334,   338,   340,   342,   344,   346,
  249.    348,   350,   355,   359,   364,   367,   370,   372,   383,   396,
  250.    398,   400,   402,   404,   409,   411,   416,   421,   428,   430,
  251.    434,   435,   439,   441,   446,   448,   450,   452,   457,   459,
  252.    464,   466,   468,   470,   472,   478,   480,   485,   487,   492,
  253.    494,   500,   502,   504,   506,   511,   513,   518,   520,   526,
  254.    528,   530,   532,   537,   540,   545,   547,   552,   558,   560,
  255.    562,   568,   570,   578,   580,   586,   588,   590,   592,   594,
  256.    599,   602,   603,   605,   607,   613,   615,   617,   619,   621,
  257.    623,   625,   627,   632,   633,   635,   637,   639,   641,   643,
  258.    645,   650,   652,   654,   659,   661,   663,   671,   675,   677,
  259.    679,   681,   684,   691,   696,   698,   700,   704,   706,   711,
  260.    713,   721,   723,   728,   732,   736,   740,   741,   745,   748
  261. };
  262.  
  263. static const char * const yytname[] = {   "$","error","$illegal.","FUNC_CALL",
  264. "NAME","REGEXP","ERROR","YNUMBER","YSTRING","RELOP","APPEND_OP","ASSIGNOP","MATCHOP",
  265. "NEWLINE","CONCAT_OP","LEX_BEGIN","LEX_END","LEX_IF","LEX_ELSE","LEX_RETURN",
  266. "LEX_DELETE","LEX_WHILE","LEX_DO","LEX_FOR","LEX_BREAK","LEX_CONTINUE","LEX_PRINT",
  267. "LEX_PRINTF","LEX_NEXT","LEX_EXIT","LEX_FUNCTION","LEX_GETLINE","LEX_IN","LEX_AND",
  268. "LEX_OR","INCREMENT","DECREMENT","LEX_BUILTIN","LEX_LENGTH","'?'","':'","'<'",
  269. "'>'","'|'","'+'","'-'","'*'","'/'","'%'","'!'","UNARY","'^'","'$'","'('","')'",
  270. "'['","']'","'{'","'}'","';'","','","start","program","rule","@1","@2","func_name",
  271. "lex_builtin","function_prologue","@3","function_body","pattern","regexp","@4",
  272. "action","statements","statement_term","statement","@5","print","if_statement",
  273. "nls","opt_nls","input_redir","output_redir","opt_param_list","param_list","opt_exp",
  274. "opt_rexpression_list","rexpression_list","opt_expression_list","expression_list",
  275. "exp","@6","rexp","@7","simp_exp","non_post_simp_exp","@8","post_inc_dec_exp",
  276. "opt_variable","variable","l_brace","r_brace","r_paren","opt_semi","semi","comma",
  277. ""
  278. };
  279. #endif
  280.  
  281. static const short yyr1[] = {     0,
  282.     61,    62,    62,    62,    62,    64,    63,    65,    63,    63,
  283.     63,    63,    63,    63,    63,    66,    66,    66,    67,    67,
  284.     69,    68,    70,    71,    71,    73,    72,    74,    74,    75,
  285.     75,    75,    75,    76,    76,    77,    77,    77,    77,    77,
  286.     77,    77,    77,    77,    77,    77,    77,    77,    77,    77,
  287.     78,    77,    77,    77,    79,    79,    80,    80,    81,    81,
  288.     82,    82,    83,    83,    84,    84,    84,    84,    85,    85,
  289.     86,    86,    86,    86,    86,    87,    87,    88,    88,    89,
  290.     89,    89,    89,    89,    89,    90,    90,    91,    91,    91,
  291.     91,    91,    91,    93,    92,    92,    92,    92,    92,    92,
  292.     92,    92,    92,    92,    92,    92,    92,    92,    92,    92,
  293.     95,    94,    94,    94,    94,    94,    94,    94,    94,    94,
  294.     94,    94,    94,    96,    96,    96,    96,    96,    96,    96,
  295.     96,    97,    97,    98,    97,    97,    97,    97,    97,    97,
  296.     97,    97,    97,    97,    99,    99,    99,   100,   100,   101,
  297.    101,   101,   101,   102,   103,   104,   105,   105,   106,   107
  298. };
  299.  
  300. static const short yyr2[] = {     0,
  301.      3,     1,     2,     1,     2,     0,     3,     0,     3,     2,
  302.      2,     2,     1,     2,     2,     1,     1,     1,     1,     1,
  303.      0,     7,     4,     1,     3,     0,     4,     5,     4,     1,
  304.      2,     1,     2,     1,     2,     2,     2,     3,     1,     6,
  305.      8,     8,    10,     9,     2,     2,     6,     4,     3,     3,
  306.      0,     4,     6,     2,     1,     1,     6,     9,     1,     2,
  307.      0,     1,     0,     2,     0,     2,     2,     2,     0,     1,
  308.      1,     3,     1,     2,     3,     0,     1,     0,     1,     1,
  309.      3,     1,     2,     3,     3,     0,     1,     1,     3,     1,
  310.      2,     3,     3,     0,     4,     5,     4,     3,     3,     3,
  311.      3,     1,     2,     3,     3,     3,     3,     5,     1,     2,
  312.      0,     4,     3,     3,     3,     1,     2,     3,     3,     3,
  313.      5,     1,     2,     1,     1,     3,     3,     3,     3,     3,
  314.      3,     2,     3,     0,     5,     4,     1,     4,     2,     2,
  315.      1,     1,     2,     2,     2,     2,     1,     0,     1,     1,
  316.      4,     2,     2,     2,     2,     1,     0,     1,     1,     2
  317. };
  318.  
  319. static const short yydefact[] = {    61,
  320.     59,    62,     0,    60,     4,     0,   150,   141,   142,     6,
  321.      8,    21,   148,     0,     0,   134,   137,     0,     0,    26,
  322.      0,     0,     0,    61,     0,     2,     0,     0,   102,    13,
  323.     24,   109,   124,   125,   147,     0,     0,     0,   159,     0,
  324.     10,    34,    61,     0,    11,     0,    63,   149,   139,   140,
  325.      0,     0,     0,     0,   144,   147,   143,     0,   103,   132,
  326.    152,   153,    90,     0,    88,   154,     5,     3,     1,    15,
  327.      0,    12,    14,     0,     0,     0,     0,     0,     0,     0,
  328.      0,     0,    61,   110,     0,     0,     0,     0,     0,     0,
  329.      0,    94,   145,   146,    32,     0,    51,     0,     0,    61,
  330.      0,     0,     0,    55,    56,    76,    76,    61,     0,    30,
  331.      0,    39,     0,     0,   157,    61,     0,     0,    88,     0,
  332.      7,    35,     9,    17,    16,    19,    20,     0,    18,     0,
  333.     98,     0,     0,     0,     0,    91,   156,     0,     0,   133,
  334.      0,   105,   101,   104,    99,   100,     0,   106,   107,   148,
  335.    160,    25,   130,   131,   127,   128,   129,   126,     0,     0,
  336.     76,     0,     0,     0,    76,    45,    46,     0,    77,     0,
  337.    155,    33,    31,   157,    82,   148,     0,     0,   116,    65,
  338.      0,    80,   122,   147,    54,     0,    37,    61,   158,    36,
  339.    138,   151,     0,    64,     0,   136,    27,    92,     0,    93,
  340.     89,   157,     0,    97,    95,     0,     0,     0,     0,     0,
  341.    150,     0,    49,    50,    61,    63,   117,     0,     0,     0,
  342.      0,     0,    83,     0,     0,     0,     0,     0,     0,     0,
  343.    123,   111,    38,    29,    73,    71,     0,     0,   135,    96,
  344.     23,   108,    61,    52,     0,    61,     0,     0,     0,    28,
  345.    115,    65,    67,    66,    68,    48,    84,    85,    81,   120,
  346.    118,   119,   113,   114,     0,     0,    61,    74,     0,     0,
  347.      0,     0,     0,     0,     0,    76,     0,     0,   112,    22,
  348.     75,    72,    57,    53,    40,     0,    61,    76,     0,    47,
  349.    121,    61,    61,     0,     0,    61,     0,    41,    42,    61,
  350.      0,    58,     0,    44,    43,     0,     0,     0
  351. };
  352.  
  353. static const short yydefgoto[] = {   306,
  354.     25,    26,    40,    44,   128,   129,    27,    46,    70,    28,
  355.     29,    58,    30,   109,    41,   110,   161,   111,   112,     2,
  356.      3,   131,   222,   237,   238,   168,   180,   181,   117,   118,
  357.     84,   159,   231,   266,    32,    33,    51,    34,    47,    35,
  358.    114,   115,   140,   188,   116,   139
  359. };
  360.  
  361. static const short yypact[] = {    15,
  362. -32768,    19,   995,-32768,-32768,   -24,   -25,-32768,-32768,    -2,
  363.     -2,-32768,     6,     6,     6,-32768,   -16,   393,   393,-32768,
  364.   1713,   393,  1087,    15,   791,-32768,   -12,    -7,-32768,-32768,
  365.    737,   189,-32768,-32768,   106,   521,  1067,  1087,-32768,   -12,
  366. -32768,    19,    15,   -12,-32768,   110,    -1,-32768,-32768,-32768,
  367.     -5,  1067,   393,  1600,    11,   -11,    11,    62,-32768,    11,
  368. -32768,-32768,-32768,    25,  1200,-32768,-32768,-32768,-32768,-32768,
  369.    627,-32768,-32768,  1600,  1600,    65,  1600,  1600,  1600,  1600,
  370.   1600,    42,    15,   914,  1600,   393,   393,   393,   393,   393,
  371.    393,-32768,-32768,-32768,-32768,    37,-32768,   114,    54,    15,
  372.     57,    -2,    -2,-32768,-32768,  1600,  1600,    15,   580,-32768,
  373.    684,-32768,   895,   521,    60,    15,    70,    26,  1299,    38,
  374. -32768,-32768,-32768,-32768,-32768,-32768,-32768,    63,-32768,   393,
  375. -32768,  1067,    70,  1200,    79,  1600,-32768,    95,  1134,-32768,
  376.    580,  1775,  1728,-32768,  1440,  1346,  1252,  1775,  1775,     6,
  377. -32768,  1299,   103,   103,    11,    11,    11,    11,  1600,  1600,
  378.   1600,    73,  1600,   838,  1647,-32768,-32768,    -2,  1299,    -2,
  379. -32768,-32768,-32768,    60,-32768,     6,  1713,  1087,-32768,    92,
  380.      4,  1487,   189,   109,-32768,   580,-32768,    15,-32768,-32768,
  381. -32768,-32768,    12,   189,    70,-32768,-32768,  1299,   126,-32768,
  382.   1299,    60,  1600,-32768,  1299,  1200,    -2,  1087,  1200,   116,
  383.    -17,    60,-32768,-32768,    15,    -1,-32768,    25,  1600,  1600,
  384.   1600,    -2,  1666,  1153,  1666,  1666,   135,  1666,  1666,  1666,
  385.    969,-32768,-32768,-32768,-32768,-32768,    70,    41,-32768,-32768,
  386. -32768,  1299,    15,-32768,    52,    15,   100,   155,  1020,-32768,
  387. -32768,    92,  1299,  1299,  1299,-32768,  1487,-32768,  1487,   703,
  388.   1790,-32768,  1581,  1534,  1393,  1666,    15,-32768,    17,   838,
  389.     -2,   838,  1600,    70,   948,  1600,    -2,  1666,  1487,-32768,
  390. -32768,-32768,   152,-32768,-32768,  1200,    15,  1600,    70,-32768,
  391.   1487,    15,    15,   838,    70,    15,   838,-32768,-32768,    15,
  392.    838,-32768,   838,-32768,-32768,   171,   177,-32768
  393. };
  394.  
  395. static const short yypgoto[] = {-32768,
  396. -32768,   153,-32768,-32768,-32768,-32768,-32768,-32768,-32768,-32768,
  397.    229,-32768,    81,   -59,   305,   101,-32768,-32768,-32768,    77,
  398.    148,   -35,   -70,-32768,-32768,  -100,-32768,-32768,   -49,   -15,
  399.     -3,-32768,   -27,-32768,   240,   162,-32768,-32768,   -61,    78,
  400.     16,  -105,   -63,  -143,   112,   -29
  401. };
  402.  
  403.  
  404. #define    YYLAST        1843
  405.  
  406.  
  407. static const short yytable[] = {    31,
  408.    138,    85,   133,   174,   223,     1,   170,    64,   187,     7,
  409.      1,   141,   235,   -79,   248,   236,   -79,   281,    36,    65,
  410.    282,    31,   120,    93,    94,   136,   136,     1,    37,    38,
  411.    215,     4,   113,   119,   119,   202,    52,    38,   136,   130,
  412.     36,   268,    71,    36,    24,   -79,   -79,   132,   119,    24,
  413.    134,    39,   136,   191,   186,    36,    39,    22,   241,    36,
  414.    207,    91,   -79,    83,   212,   -69,   135,   113,   144,   196,
  415.    142,   143,   150,   145,   146,   147,   148,   149,   137,   -87,
  416.    233,   152,   195,   182,    83,    83,    42,    42,   204,   160,
  417.     48,    49,    50,   192,   -70,    56,    56,    83,    56,    62,
  418.     83,   219,   169,   169,    42,   113,   163,   271,    72,   165,
  419.    113,    83,   124,   125,   216,   193,    92,   162,    39,   232,
  420.    121,    43,    43,   137,   123,   197,   199,   208,   119,   240,
  421.     56,   239,   198,   220,   221,   201,   247,   113,   262,    43,
  422.     93,    94,   243,    93,    94,   246,   126,   127,    88,    89,
  423.     90,   224,   273,    91,   252,   205,   206,   169,   274,   209,
  424.    113,   169,   218,    56,    56,    56,    56,    56,    56,   292,
  425.    307,    66,    69,   267,    65,   289,   308,    68,    42,    42,
  426.    251,   277,   113,    61,     0,     0,     0,   295,   184,    42,
  427.    122,     0,   245,     0,     0,   257,   259,   260,   261,   242,
  428.    263,   264,   265,     0,   119,     0,     0,    56,   269,   173,
  429.    287,     0,     0,    43,    43,   253,   254,   255,     0,     0,
  430.      0,     0,   293,     0,    43,   296,   189,    48,     0,     0,
  431.    151,   300,    86,    87,    88,    89,    90,     0,   279,    91,
  432.      0,   173,     0,     0,    42,   275,    42,   164,     0,    59,
  433.    291,     0,     0,    48,    56,   171,     0,    55,    57,   184,
  434.     60,     0,     0,   190,   210,     0,   113,     0,   113,   286,
  435.      0,     0,   169,     0,     0,     0,     0,     0,     0,    43,
  436.      0,    43,     0,    42,   169,   189,   173,     0,     0,     0,
  437.    113,     0,    60,   113,     0,     0,     0,   113,    42,   113,
  438.    184,   184,   184,   184,     0,   184,   184,   184,   184,     0,
  439.      0,     0,     0,   189,     0,    45,     0,     0,    43,     0,
  440.      0,     0,     0,   249,     0,   153,   154,   155,   156,   157,
  441.    158,     0,    73,    43,   184,   234,   184,   184,   184,   179,
  442.    184,   184,   184,   184,     0,     0,     0,    42,     0,     0,
  443.    183,     0,     0,    42,     0,   184,   184,     0,     0,     0,
  444.    276,     0,   250,     0,     0,     0,     0,     0,   184,   194,
  445.    283,     0,   285,     0,     0,     0,     0,     0,     0,     0,
  446.      0,     0,    43,     0,     0,     0,   288,     0,    43,     0,
  447.    270,     0,     0,   272,   299,     6,     7,   302,     0,     8,
  448.      9,   304,     0,   305,     0,   217,   166,   167,     0,     0,
  449.    179,     0,     0,     0,   280,     0,    60,   185,     0,     0,
  450.      0,   183,     0,     0,     0,     0,     0,    14,    15,    16,
  451.     17,     0,     0,     0,   294,     0,    18,    19,     0,   297,
  452.    298,    53,     0,   301,    22,    54,     0,   303,     0,     0,
  453.      0,   179,   179,   179,   179,     0,   179,   179,   179,   179,
  454.      0,     0,   183,   183,   183,   183,     0,   183,   183,   183,
  455.    183,     0,   213,     0,   214,     0,     0,     0,     0,     0,
  456.      0,     0,     0,     0,     0,   179,     0,   179,   179,   179,
  457.      0,   179,   179,   179,   179,     0,   183,     0,   183,   183,
  458.    183,     0,   183,   183,   183,   183,   179,   179,     0,     0,
  459.      0,   244,     0,     0,     0,     0,     0,   183,   183,   179,
  460.      0,    95,     0,     6,     7,     0,   256,     8,     9,     0,
  461.    183,     0,     0,     0,     0,     0,     0,    96,     0,    97,
  462.     98,    99,   100,   101,   102,   103,   104,   105,   106,   107,
  463.      0,    13,     0,     0,     0,    14,    15,    16,    17,     0,
  464.      0,     0,     0,     0,    18,    19,     0,    20,     0,    21,
  465.      0,     0,    22,    23,     0,   284,     0,    24,   108,    39,
  466.    172,   290,     6,     7,     0,     0,     8,     9,     0,     0,
  467.      0,     0,     0,     0,     0,     0,    96,     0,    97,    98,
  468.     99,   100,   101,   102,   103,   104,   105,   106,   107,     0,
  469.     13,     0,     0,     0,    14,    15,    16,    17,     0,     0,
  470.      0,     0,     0,    18,    19,     0,    20,    95,    21,     6,
  471.      7,    22,    23,     8,     9,     0,    24,   108,    39,     0,
  472.      0,     0,     0,    96,     0,    97,    98,    99,   100,   101,
  473.    102,   103,   104,   105,   106,   107,     0,    13,     0,     0,
  474.      0,    14,    15,    16,    17,     0,     0,     0,     0,     0,
  475.     18,    19,     0,    20,     0,    21,     0,     0,    22,    23,
  476.      0,     0,     0,    24,   175,    39,     6,     7,     0,     0,
  477.      8,     9,     0,   -78,     0,     0,   -78,     0,     0,     0,
  478.      0,     0,     0,     0,     0,     0,     7,     0,     0,     8,
  479.      9,-32768,     0,     0,   176,     0,     0,     0,    14,    15,
  480.     16,    17,     0,     0,     0,   -78,   -78,    18,    19,     0,
  481.     20,     0,   177,     0,     0,    22,   178,    14,    15,     6,
  482.      7,     0,   -78,     8,     9,    74,    18,    19,    75,    20,
  483.      0,   177,     0,     0,    22,    54,     0,     0,     0,     0,
  484.      0,     0,     0,     0,     0,     0,     0,    13,    76,    77,
  485.     78,    14,    15,    16,    17,    79,     0,    80,    81,    82,
  486.     18,    19,     0,    20,     0,    21,     0,     0,    22,    23,
  487.    -61,    67,     0,     6,     7,     0,    83,     8,     9,     0,
  488.      0,     0,     0,     1,     0,    10,    11,     0,     0,     0,
  489.      0,     0,     0,     0,     0,     0,     0,     0,     0,     0,
  490.     12,    13,     0,     0,     0,    14,    15,    16,    17,     0,
  491.      0,     0,     0,     0,    18,    19,     0,    20,     0,    21,
  492.      6,     7,    22,    23,     8,     9,     0,    24,     0,     0,
  493.      0,     0,     0,     0,    96,     0,    97,    98,    99,   100,
  494.    101,   102,   103,   104,   105,   106,   107,     0,    13,     0,
  495.      0,     0,    14,    15,    16,    17,     0,     0,     0,     0,
  496.      0,    18,    19,     0,    20,     0,    21,     0,     0,    22,
  497.     23,     0,     0,     0,    24,     0,    39,     6,     7,     0,
  498.      0,     8,     9,    74,     0,     0,    75,     1,     0,     0,
  499.      0,     0,     0,     0,     0,     0,     0,     7,     0,     0,
  500.      8,     9,     0,     0,     0,    13,    76,    77,    78,    14,
  501.     15,    16,    17,    79,     0,    80,    81,    82,    18,    19,
  502.      0,    20,     0,    21,     0,     0,    22,    23,    14,    15,
  503.      6,     7,     0,    39,     8,     9,    74,    18,    19,    75,
  504.     20,     0,    21,     0,     0,    22,    23,     0,     0,     0,
  505.      0,     0,     7,     0,     0,     8,     9,     0,    13,    76,
  506.     77,    78,    14,    15,    16,    17,    79,     0,    80,    81,
  507.     82,    18,    19,     0,    20,     5,    21,     6,     7,    22,
  508.     23,     8,     9,    14,    15,     0,    39,     0,     0,    10,
  509.     11,     0,    18,    19,     0,    20,     0,   177,     0,     0,
  510.     22,    54,     6,     7,    12,    13,     8,     9,     0,    14,
  511.     15,    16,    17,     0,     0,     0,     0,     0,    18,    19,
  512.      0,    20,     0,    21,     0,     0,    22,    23,     0,     0,
  513.     13,    24,     0,     0,    14,    15,    16,    17,     0,     0,
  514.      0,     0,     0,    18,    19,     0,    20,    63,    21,     6,
  515.      7,    22,    23,     8,     9,     0,     0,     0,    39,     0,
  516.      0,     0,     0,     0,     0,     0,     0,    63,     0,     6,
  517.      7,     0,     0,     8,     9,     0,     0,    13,     0,     0,
  518.      0,    14,    15,    16,    17,     0,     0,     0,     0,     0,
  519.     18,    19,     0,    20,     0,    21,     0,    13,    22,    23,
  520.    -86,    14,    15,    16,    17,     0,     0,     0,     0,     0,
  521.     18,    19,     0,    20,   200,    21,     6,     7,    22,    23,
  522.      8,     9,     0,     0,     0,     0,     0,     0,     0,     0,
  523.      0,     0,     0,   258,     0,     6,     7,     0,     0,     8,
  524.      9,     0,     0,     0,    13,     0,     0,     0,    14,    15,
  525.     16,    17,     0,     0,     0,     0,     0,    18,    19,     0,
  526.     20,     0,    21,   176,     0,    22,    23,    14,    15,    16,
  527.     17,     0,     0,     0,     0,     0,    18,    19,     0,    20,
  528.      0,   177,     6,     7,    22,    54,     8,     9,    74,     0,
  529.      0,    75,     0,     0,     0,     0,     0,     0,     0,     0,
  530.      0,     0,     0,     0,     0,     0,     0,     0,     0,     0,
  531.     13,    76,    77,    78,    14,    15,    16,    17,    79,     0,
  532.     80,    81,    82,    18,    19,     0,    20,     0,    21,     0,
  533.      0,    22,    23,   137,     6,     7,     0,     0,     8,     9,
  534.     74,     0,     0,    75,     0,     0,     0,     0,     0,     0,
  535.      0,     0,     0,     0,     0,     0,     0,     0,     0,     0,
  536.      0,     0,    13,    76,    77,    78,    14,    15,    16,    17,
  537.     79,   203,    80,    81,    82,    18,    19,     0,    20,     0,
  538.     21,     6,     7,    22,    23,     8,     9,    74,     0,     0,
  539.     75,     0,     0,     0,     0,     0,     0,     0,     0,     0,
  540.      0,     0,     0,     0,     0,     0,     0,     0,     0,    13,
  541.     76,    77,    78,    14,    15,    16,    17,    79,     0,    80,
  542.     81,    82,    18,    19,     0,    20,     0,    21,     6,     7,
  543.     22,    23,     8,     9,    74,     0,     0,    75,     0,     0,
  544.      0,     0,     0,     0,     0,     0,     0,     0,     0,     0,
  545.      0,     0,     0,     0,     0,     0,    13,    76,    77,     0,
  546.     14,    15,    16,    17,     0,     0,    80,    81,    82,    18,
  547.     19,     0,    20,     0,    21,     6,     7,    22,    23,     8,
  548.      9,   225,     0,     0,   226,     0,     0,     0,     0,     0,
  549.      0,     0,     0,     0,     0,     0,     0,     0,     0,     0,
  550.      0,     0,     0,   176,   227,   228,   229,    14,    15,    16,
  551.     17,   230,   278,     0,     0,     0,    18,    19,     0,    20,
  552.      0,   177,     6,     7,    22,    54,     8,     9,    74,     0,
  553.      0,    75,     0,     0,     0,     0,     0,     0,     0,     0,
  554.      0,     0,     0,     0,     0,     0,     0,     0,     0,     0,
  555.     13,    76,     0,     0,    14,    15,    16,    17,     0,     0,
  556.     80,    81,    82,    18,    19,     0,    20,     0,    21,     6,
  557.      7,    22,    23,     8,     9,   225,     0,     0,   226,     0,
  558.      0,     0,     0,     0,     0,     0,     0,     0,     0,     0,
  559.      0,     0,     0,     0,     0,     0,     0,   176,   227,   228,
  560.    229,    14,    15,    16,    17,   230,     0,     0,     0,     0,
  561.     18,    19,     0,    20,     0,   177,     6,     7,    22,    54,
  562.      8,     9,   225,     0,     0,   226,     0,     0,     0,     0,
  563.      0,     0,     0,     0,     0,     0,     0,     0,     0,     0,
  564.      0,     0,     0,     0,   176,   227,   228,     0,    14,    15,
  565.     16,    17,     0,     0,     0,     0,     0,    18,    19,     0,
  566.     20,     0,   177,     6,     7,    22,    54,     8,     9,   225,
  567.      0,     0,   226,     0,     0,     0,     0,     0,     0,     0,
  568.      0,     0,     6,     7,     0,     0,     8,     9,     0,     0,
  569.      0,   176,   227,     0,     0,    14,    15,    16,    17,     0,
  570.      0,     0,     0,     0,    18,    19,     0,    20,     0,   177,
  571.     13,     0,    22,    54,    14,    15,    16,    17,     0,     0,
  572.      0,     0,     0,    18,    19,     0,    20,     0,    21,     6,
  573.    211,    22,    23,     8,     9,     0,     0,     0,     0,     0,
  574.      0,     0,     0,     0,     0,     0,     0,     0,     6,     7,
  575.      0,     0,     8,     9,     0,     0,     0,    13,     0,     0,
  576.      0,    14,    15,    16,    17,     0,     0,     0,     0,     0,
  577.     18,    19,     0,    20,     0,    21,   176,     0,    22,    23,
  578.     14,    15,    16,    17,     0,     0,     0,     0,     0,    18,
  579.     19,     0,    20,     0,   177,     6,     7,    22,    54,     8,
  580.      9,     0,     0,     0,     0,     0,     0,     0,     0,     0,
  581.      0,     7,     0,     0,     8,     9,    74,     0,     0,-32768,
  582.      0,     0,     0,     0,     0,     0,     0,    14,    15,    16,
  583.     17,     0,     0,     0,     0,     0,    18,    19,     0,    20,
  584.      0,    53,    14,    15,    22,    54,     0,     0,    80,    81,
  585.     82,    18,    19,     0,    20,     0,    21,     0,     7,    22,
  586.     23,     8,     9,-32768,     0,     0,     0,     0,     0,     0,
  587.      0,     0,     0,     7,     0,     0,     8,     9,   225,     0,
  588.      0,-32768,     0,     0,     0,     0,     0,     0,     0,    14,
  589.     15,     0,     0,     0,     0,-32768,-32768,-32768,    18,    19,
  590.      0,    20,     0,    21,    14,    15,    22,    23,     0,     0,
  591.      0,     0,     0,    18,    19,     0,    20,     0,   177,     0,
  592.      0,    22,    54
  593. };
  594.  
  595. static const short yycheck[] = {     3,
  596.     64,    31,    52,   109,     1,    13,   107,    23,   114,     4,
  597.     13,    71,     1,    10,    32,     4,    13,     1,     3,    23,
  598.      4,    25,    38,    35,    36,     1,     1,    13,    53,    55,
  599.    174,    13,    36,    37,    38,   141,    53,    55,     1,    41,
  600.     25,     1,    27,    28,    57,    42,    43,    53,    52,    57,
  601.     54,    59,     1,   117,   114,    40,    59,    52,   202,    44,
  602.    161,    51,    59,    60,   165,    54,     5,    71,     4,   133,
  603.     74,    75,    31,    77,    78,    79,    80,    81,    54,    54,
  604.    186,    85,   132,   111,    60,    60,    10,    11,   150,    53,
  605.     13,    14,    15,    56,    54,    18,    19,    60,    21,    22,
  606.     60,    10,   106,   107,    28,   109,    53,    56,    28,    53,
  607.    114,    60,     3,     4,   176,    53,    11,     4,    59,    11,
  608.     40,    10,    11,    54,    44,    47,    32,    55,   132,     4,
  609.     53,   195,   136,    42,    43,   139,    21,   141,     4,    28,
  610.     35,    36,   206,    35,    36,   209,    37,    38,    46,    47,
  611.     48,   181,    53,    51,   218,   159,   160,   161,     4,   163,
  612.    164,   165,   178,    86,    87,    88,    89,    90,    91,    18,
  613.      0,    24,    25,   237,   178,   276,     0,    25,   102,   103,
  614.    216,   252,   186,    22,    -1,    -1,    -1,   288,   111,   113,
  615.     43,    -1,   208,    -1,    -1,   223,   224,   225,   226,   203,
  616.    228,   229,   230,    -1,   208,    -1,    -1,   130,   238,   109,
  617.    274,    -1,    -1,   102,   103,   219,   220,   221,    -1,    -1,
  618.     -1,    -1,   286,    -1,   113,   289,   115,   150,    -1,    -1,
  619.     83,   295,    44,    45,    46,    47,    48,    -1,   266,    51,
  620.     -1,   141,    -1,    -1,   168,   249,   170,   100,    -1,    21,
  621.    278,    -1,    -1,   176,   177,   108,    -1,    18,    19,   182,
  622.     21,    -1,    -1,   116,   164,    -1,   270,    -1,   272,   273,
  623.     -1,    -1,   276,    -1,    -1,    -1,    -1,    -1,    -1,   168,
  624.     -1,   170,    -1,   207,   288,   174,   186,    -1,    -1,    -1,
  625.    294,    -1,    53,   297,    -1,    -1,    -1,   301,   222,   303,
  626.    223,   224,   225,   226,    -1,   228,   229,   230,   231,    -1,
  627.     -1,    -1,    -1,   202,    -1,    11,    -1,    -1,   207,    -1,
  628.     -1,    -1,    -1,   212,    -1,    86,    87,    88,    89,    90,
  629.     91,    -1,    28,   222,   257,   188,   259,   260,   261,   111,
  630.    263,   264,   265,   266,    -1,    -1,    -1,   271,    -1,    -1,
  631.    111,    -1,    -1,   277,    -1,   278,   279,    -1,    -1,    -1,
  632.    249,    -1,   215,    -1,    -1,    -1,    -1,    -1,   291,   130,
  633.    270,    -1,   272,    -1,    -1,    -1,    -1,    -1,    -1,    -1,
  634.     -1,    -1,   271,    -1,    -1,    -1,   275,    -1,   277,    -1,
  635.    243,    -1,    -1,   246,   294,     3,     4,   297,    -1,     7,
  636.      8,   301,    -1,   303,    -1,   177,   102,   103,    -1,    -1,
  637.    182,    -1,    -1,    -1,   267,    -1,   177,   113,    -1,    -1,
  638.     -1,   182,    -1,    -1,    -1,    -1,    -1,    35,    36,    37,
  639.     38,    -1,    -1,    -1,   287,    -1,    44,    45,    -1,   292,
  640.    293,    49,    -1,   296,    52,    53,    -1,   300,    -1,    -1,
  641.     -1,   223,   224,   225,   226,    -1,   228,   229,   230,   231,
  642.     -1,    -1,   223,   224,   225,   226,    -1,   228,   229,   230,
  643.    231,    -1,   168,    -1,   170,    -1,    -1,    -1,    -1,    -1,
  644.     -1,    -1,    -1,    -1,    -1,   257,    -1,   259,   260,   261,
  645.     -1,   263,   264,   265,   266,    -1,   257,    -1,   259,   260,
  646.    261,    -1,   263,   264,   265,   266,   278,   279,    -1,    -1,
  647.     -1,   207,    -1,    -1,    -1,    -1,    -1,   278,   279,   291,
  648.     -1,     1,    -1,     3,     4,    -1,   222,     7,     8,    -1,
  649.    291,    -1,    -1,    -1,    -1,    -1,    -1,    17,    -1,    19,
  650.     20,    21,    22,    23,    24,    25,    26,    27,    28,    29,
  651.     -1,    31,    -1,    -1,    -1,    35,    36,    37,    38,    -1,
  652.     -1,    -1,    -1,    -1,    44,    45,    -1,    47,    -1,    49,
  653.     -1,    -1,    52,    53,    -1,   271,    -1,    57,    58,    59,
  654.      1,   277,     3,     4,    -1,    -1,     7,     8,    -1,    -1,
  655.     -1,    -1,    -1,    -1,    -1,    -1,    17,    -1,    19,    20,
  656.     21,    22,    23,    24,    25,    26,    27,    28,    29,    -1,
  657.     31,    -1,    -1,    -1,    35,    36,    37,    38,    -1,    -1,
  658.     -1,    -1,    -1,    44,    45,    -1,    47,     1,    49,     3,
  659.      4,    52,    53,     7,     8,    -1,    57,    58,    59,    -1,
  660.     -1,    -1,    -1,    17,    -1,    19,    20,    21,    22,    23,
  661.     24,    25,    26,    27,    28,    29,    -1,    31,    -1,    -1,
  662.     -1,    35,    36,    37,    38,    -1,    -1,    -1,    -1,    -1,
  663.     44,    45,    -1,    47,    -1,    49,    -1,    -1,    52,    53,
  664.     -1,    -1,    -1,    57,     1,    59,     3,     4,    -1,    -1,
  665.      7,     8,    -1,    10,    -1,    -1,    13,    -1,    -1,    -1,
  666.     -1,    -1,    -1,    -1,    -1,    -1,     4,    -1,    -1,     7,
  667.      8,     9,    -1,    -1,    31,    -1,    -1,    -1,    35,    36,
  668.     37,    38,    -1,    -1,    -1,    42,    43,    44,    45,    -1,
  669.     47,    -1,    49,    -1,    -1,    52,    53,    35,    36,     3,
  670.      4,    -1,    59,     7,     8,     9,    44,    45,    12,    47,
  671.     -1,    49,    -1,    -1,    52,    53,    -1,    -1,    -1,    -1,
  672.     -1,    -1,    -1,    -1,    -1,    -1,    -1,    31,    32,    33,
  673.     34,    35,    36,    37,    38,    39,    -1,    41,    42,    43,
  674.     44,    45,    -1,    47,    -1,    49,    -1,    -1,    52,    53,
  675.      0,     1,    -1,     3,     4,    -1,    60,     7,     8,    -1,
  676.     -1,    -1,    -1,    13,    -1,    15,    16,    -1,    -1,    -1,
  677.     -1,    -1,    -1,    -1,    -1,    -1,    -1,    -1,    -1,    -1,
  678.     30,    31,    -1,    -1,    -1,    35,    36,    37,    38,    -1,
  679.     -1,    -1,    -1,    -1,    44,    45,    -1,    47,    -1,    49,
  680.      3,     4,    52,    53,     7,     8,    -1,    57,    -1,    -1,
  681.     -1,    -1,    -1,    -1,    17,    -1,    19,    20,    21,    22,
  682.     23,    24,    25,    26,    27,    28,    29,    -1,    31,    -1,
  683.     -1,    -1,    35,    36,    37,    38,    -1,    -1,    -1,    -1,
  684.     -1,    44,    45,    -1,    47,    -1,    49,    -1,    -1,    52,
  685.     53,    -1,    -1,    -1,    57,    -1,    59,     3,     4,    -1,
  686.     -1,     7,     8,     9,    -1,    -1,    12,    13,    -1,    -1,
  687.     -1,    -1,    -1,    -1,    -1,    -1,    -1,     4,    -1,    -1,
  688.      7,     8,    -1,    -1,    -1,    31,    32,    33,    34,    35,
  689.     36,    37,    38,    39,    -1,    41,    42,    43,    44,    45,
  690.     -1,    47,    -1,    49,    -1,    -1,    52,    53,    35,    36,
  691.      3,     4,    -1,    59,     7,     8,     9,    44,    45,    12,
  692.     47,    -1,    49,    -1,    -1,    52,    53,    -1,    -1,    -1,
  693.     -1,    -1,     4,    -1,    -1,     7,     8,    -1,    31,    32,
  694.     33,    34,    35,    36,    37,    38,    39,    -1,    41,    42,
  695.     43,    44,    45,    -1,    47,     1,    49,     3,     4,    52,
  696.     53,     7,     8,    35,    36,    -1,    59,    -1,    -1,    15,
  697.     16,    -1,    44,    45,    -1,    47,    -1,    49,    -1,    -1,
  698.     52,    53,     3,     4,    30,    31,     7,     8,    -1,    35,
  699.     36,    37,    38,    -1,    -1,    -1,    -1,    -1,    44,    45,
  700.     -1,    47,    -1,    49,    -1,    -1,    52,    53,    -1,    -1,
  701.     31,    57,    -1,    -1,    35,    36,    37,    38,    -1,    -1,
  702.     -1,    -1,    -1,    44,    45,    -1,    47,     1,    49,     3,
  703.      4,    52,    53,     7,     8,    -1,    -1,    -1,    59,    -1,
  704.     -1,    -1,    -1,    -1,    -1,    -1,    -1,     1,    -1,     3,
  705.      4,    -1,    -1,     7,     8,    -1,    -1,    31,    -1,    -1,
  706.     -1,    35,    36,    37,    38,    -1,    -1,    -1,    -1,    -1,
  707.     44,    45,    -1,    47,    -1,    49,    -1,    31,    52,    53,
  708.     54,    35,    36,    37,    38,    -1,    -1,    -1,    -1,    -1,
  709.     44,    45,    -1,    47,     1,    49,     3,     4,    52,    53,
  710.      7,     8,    -1,    -1,    -1,    -1,    -1,    -1,    -1,    -1,
  711.     -1,    -1,    -1,     1,    -1,     3,     4,    -1,    -1,     7,
  712.      8,    -1,    -1,    -1,    31,    -1,    -1,    -1,    35,    36,
  713.     37,    38,    -1,    -1,    -1,    -1,    -1,    44,    45,    -1,
  714.     47,    -1,    49,    31,    -1,    52,    53,    35,    36,    37,
  715.     38,    -1,    -1,    -1,    -1,    -1,    44,    45,    -1,    47,
  716.     -1,    49,     3,     4,    52,    53,     7,     8,     9,    -1,
  717.     -1,    12,    -1,    -1,    -1,    -1,    -1,    -1,    -1,    -1,
  718.     -1,    -1,    -1,    -1,    -1,    -1,    -1,    -1,    -1,    -1,
  719.     31,    32,    33,    34,    35,    36,    37,    38,    39,    -1,
  720.     41,    42,    43,    44,    45,    -1,    47,    -1,    49,    -1,
  721.     -1,    52,    53,    54,     3,     4,    -1,    -1,     7,     8,
  722.      9,    -1,    -1,    12,    -1,    -1,    -1,    -1,    -1,    -1,
  723.     -1,    -1,    -1,    -1,    -1,    -1,    -1,    -1,    -1,    -1,
  724.     -1,    -1,    31,    32,    33,    34,    35,    36,    37,    38,
  725.     39,    40,    41,    42,    43,    44,    45,    -1,    47,    -1,
  726.     49,     3,     4,    52,    53,     7,     8,     9,    -1,    -1,
  727.     12,    -1,    -1,    -1,    -1,    -1,    -1,    -1,    -1,    -1,
  728.     -1,    -1,    -1,    -1,    -1,    -1,    -1,    -1,    -1,    31,
  729.     32,    33,    34,    35,    36,    37,    38,    39,    -1,    41,
  730.     42,    43,    44,    45,    -1,    47,    -1,    49,     3,     4,
  731.     52,    53,     7,     8,     9,    -1,    -1,    12,    -1,    -1,
  732.     -1,    -1,    -1,    -1,    -1,    -1,    -1,    -1,    -1,    -1,
  733.     -1,    -1,    -1,    -1,    -1,    -1,    31,    32,    33,    -1,
  734.     35,    36,    37,    38,    -1,    -1,    41,    42,    43,    44,
  735.     45,    -1,    47,    -1,    49,     3,     4,    52,    53,     7,
  736.      8,     9,    -1,    -1,    12,    -1,    -1,    -1,    -1,    -1,
  737.     -1,    -1,    -1,    -1,    -1,    -1,    -1,    -1,    -1,    -1,
  738.     -1,    -1,    -1,    31,    32,    33,    34,    35,    36,    37,
  739.     38,    39,    40,    -1,    -1,    -1,    44,    45,    -1,    47,
  740.     -1,    49,     3,     4,    52,    53,     7,     8,     9,    -1,
  741.     -1,    12,    -1,    -1,    -1,    -1,    -1,    -1,    -1,    -1,
  742.     -1,    -1,    -1,    -1,    -1,    -1,    -1,    -1,    -1,    -1,
  743.     31,    32,    -1,    -1,    35,    36,    37,    38,    -1,    -1,
  744.     41,    42,    43,    44,    45,    -1,    47,    -1,    49,     3,
  745.      4,    52,    53,     7,     8,     9,    -1,    -1,    12,    -1,
  746.     -1,    -1,    -1,    -1,    -1,    -1,    -1,    -1,    -1,    -1,
  747.     -1,    -1,    -1,    -1,    -1,    -1,    -1,    31,    32,    33,
  748.     34,    35,    36,    37,    38,    39,    -1,    -1,    -1,    -1,
  749.     44,    45,    -1,    47,    -1,    49,     3,     4,    52,    53,
  750.      7,     8,     9,    -1,    -1,    12,    -1,    -1,    -1,    -1,
  751.     -1,    -1,    -1,    -1,    -1,    -1,    -1,    -1,    -1,    -1,
  752.     -1,    -1,    -1,    -1,    31,    32,    33,    -1,    35,    36,
  753.     37,    38,    -1,    -1,    -1,    -1,    -1,    44,    45,    -1,
  754.     47,    -1,    49,     3,     4,    52,    53,     7,     8,     9,
  755.     -1,    -1,    12,    -1,    -1,    -1,    -1,    -1,    -1,    -1,
  756.     -1,    -1,     3,     4,    -1,    -1,     7,     8,    -1,    -1,
  757.     -1,    31,    32,    -1,    -1,    35,    36,    37,    38,    -1,
  758.     -1,    -1,    -1,    -1,    44,    45,    -1,    47,    -1,    49,
  759.     31,    -1,    52,    53,    35,    36,    37,    38,    -1,    -1,
  760.     -1,    -1,    -1,    44,    45,    -1,    47,    -1,    49,     3,
  761.      4,    52,    53,     7,     8,    -1,    -1,    -1,    -1,    -1,
  762.     -1,    -1,    -1,    -1,    -1,    -1,    -1,    -1,     3,     4,
  763.     -1,    -1,     7,     8,    -1,    -1,    -1,    31,    -1,    -1,
  764.     -1,    35,    36,    37,    38,    -1,    -1,    -1,    -1,    -1,
  765.     44,    45,    -1,    47,    -1,    49,    31,    -1,    52,    53,
  766.     35,    36,    37,    38,    -1,    -1,    -1,    -1,    -1,    44,
  767.     45,    -1,    47,    -1,    49,     3,     4,    52,    53,     7,
  768.      8,    -1,    -1,    -1,    -1,    -1,    -1,    -1,    -1,    -1,
  769.     -1,     4,    -1,    -1,     7,     8,     9,    -1,    -1,    12,
  770.     -1,    -1,    -1,    -1,    -1,    -1,    -1,    35,    36,    37,
  771.     38,    -1,    -1,    -1,    -1,    -1,    44,    45,    -1,    47,
  772.     -1,    49,    35,    36,    52,    53,    -1,    -1,    41,    42,
  773.     43,    44,    45,    -1,    47,    -1,    49,    -1,     4,    52,
  774.     53,     7,     8,     9,    -1,    -1,    -1,    -1,    -1,    -1,
  775.     -1,    -1,    -1,     4,    -1,    -1,     7,     8,     9,    -1,
  776.     -1,    12,    -1,    -1,    -1,    -1,    -1,    -1,    -1,    35,
  777.     36,    -1,    -1,    -1,    -1,    41,    42,    43,    44,    45,
  778.     -1,    47,    -1,    49,    35,    36,    52,    53,    -1,    -1,
  779.     -1,    -1,    -1,    44,    45,    -1,    47,    -1,    49,    -1,
  780.     -1,    52,    53
  781. };
  782. /* -*-C-*-  Note some compilers choke on comments on `#line' lines.  */
  783. #line 3 "bison.simple"
  784.  
  785. /* Skeleton output parser for bison,
  786.    Copyright (C) 1984, 1989, 1990 Bob Corbett and Richard Stallman
  787.  
  788.    This program is free software; you can redistribute it and/or modify
  789.    it under the terms of the GNU General Public License as published by
  790.    the Free Software Foundation; either version 1, or (at your option)
  791.    any later version.
  792.  
  793.    This program is distributed in the hope that it will be useful,
  794.    but WITHOUT ANY WARRANTY; without even the implied warranty of
  795.    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
  796.    GNU General Public License for more details.
  797.  
  798.    You should have received a copy of the GNU General Public License
  799.    along with this program; if not, write to the Free Software
  800.    Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.  */
  801.  
  802. #ifndef alloca
  803. #ifdef __GNUC__
  804. #define alloca __builtin_alloca
  805. #else /* not GNU C.  */
  806. #if (!defined (__STDC__) && defined (sparc)) || defined (__sparc__)
  807. #include <alloca.h>
  808. #else /* not sparc */
  809. #if defined (MSDOS) && !defined (__TURBOC__)
  810. #include <malloc.h>
  811. #else /* not MSDOS, or __TURBOC__ */
  812. #if defined(_AIX)
  813. #include <malloc.h>
  814.  #pragma alloca
  815. #endif /* not _AIX */
  816. #endif /* not MSDOS, or __TURBOC__ */
  817. #endif /* not sparc.  */
  818. #endif /* not GNU C.  */
  819. #endif /* alloca not defined.  */
  820.  
  821. /* This is the parser code that is written into each bison parser
  822.   when the %semantic_parser declaration is not specified in the grammar.
  823.   It was written by Richard Stallman by simplifying the hairy parser
  824.   used when %semantic_parser is specified.  */
  825.  
  826. /* Note: there must be only one dollar sign in this file.
  827.    It is replaced by the list of actions, each action
  828.    as one case of the switch.  */
  829.  
  830. #define yyerrok        (yyerrstatus = 0)
  831. #define yyclearin    (yychar = YYEMPTY)
  832. #define YYEMPTY        -2
  833. #define YYEOF        0
  834. #define YYACCEPT    return(0)
  835. #define YYABORT     return(1)
  836. #define YYERROR        goto yyerrlab1
  837. /* Like YYERROR except do call yyerror.
  838.    This remains here temporarily to ease the
  839.    transition to the new meaning of YYERROR, for GCC.
  840.    Once GCC version 2 has supplanted version 1, this can go.  */
  841. #define YYFAIL        goto yyerrlab
  842. #define YYRECOVERING()  (!!yyerrstatus)
  843. #define YYBACKUP(token, value) \
  844. do                                \
  845.   if (yychar == YYEMPTY && yylen == 1)                \
  846.     { yychar = (token), yylval = (value);            \
  847.       yychar1 = YYTRANSLATE (yychar);                \
  848.       YYPOPSTACK;                        \
  849.       goto yybackup;                        \
  850.     }                                \
  851.   else                                \
  852.     { yyerror ("syntax error: cannot back up"); YYERROR; }    \
  853. while (0)
  854.  
  855. #define YYTERROR    1
  856. #define YYERRCODE    256
  857.  
  858. #ifndef YYPURE
  859. #define YYLEX        yylex()
  860. #endif
  861.  
  862. #ifdef YYPURE
  863. #ifdef YYLSP_NEEDED
  864. #define YYLEX        yylex(&yylval, &yylloc)
  865. #else
  866. #define YYLEX        yylex(&yylval)
  867. #endif
  868. #endif
  869.  
  870. /* If nonreentrant, generate the variables here */
  871.  
  872. #ifndef YYPURE
  873.  
  874. int    yychar;            /*  the lookahead symbol        */
  875. YYSTYPE    yylval;            /*  the semantic value of the        */
  876.                 /*  lookahead symbol            */
  877.  
  878. #ifdef YYLSP_NEEDED
  879. YYLTYPE yylloc;            /*  location data for the lookahead    */
  880.                 /*  symbol                */
  881. #endif
  882.  
  883. int yynerrs;            /*  number of parse errors so far       */
  884. #endif  /* not YYPURE */
  885.  
  886. #if YYDEBUG != 0
  887. int yydebug;            /*  nonzero means print parse trace    */
  888. /* Since this is uninitialized, it does not stop multiple parsers
  889.    from coexisting.  */
  890. #endif
  891.  
  892. /*  YYINITDEPTH indicates the initial size of the parser's stacks    */
  893.  
  894. #ifndef    YYINITDEPTH
  895. #define YYINITDEPTH 200
  896. #endif
  897.  
  898. /*  YYMAXDEPTH is the maximum size the stacks can grow to
  899.     (effective only if the built-in stack extension method is used).  */
  900.  
  901. #if YYMAXDEPTH == 0
  902. #undef YYMAXDEPTH
  903. #endif
  904.  
  905. #ifndef YYMAXDEPTH
  906. #define YYMAXDEPTH 10000
  907. #endif
  908.  
  909. #if __GNUC__ > 1        /* GNU C and GNU C++ define this.  */
  910. #define __yy_bcopy(FROM,TO,COUNT)    __builtin_memcpy(TO,FROM,COUNT)
  911. #else                /* not GNU C or C++ */
  912. #ifndef __cplusplus
  913.  
  914. /* This is the most reliable way to avoid incompatibilities
  915.    in available built-in functions on various systems.  */
  916. static void
  917. __yy_bcopy (from, to, count)
  918.      char *from;
  919.      char *to;
  920.      int count;
  921. {
  922.   register char *f = from;
  923.   register char *t = to;
  924.   register int i = count;
  925.  
  926.   while (i-- > 0)
  927.     *t++ = *f++;
  928. }
  929.  
  930. #else /* __cplusplus */
  931.  
  932. /* This is the most reliable way to avoid incompatibilities
  933.    in available built-in functions on various systems.  */
  934. static void
  935. __yy_bcopy (char *from, char *to, int count)
  936. {
  937.   register char *f = from;
  938.   register char *t = to;
  939.   register int i = count;
  940.  
  941.   while (i-- > 0)
  942.     *t++ = *f++;
  943. }
  944.  
  945. #endif
  946. #endif
  947.  
  948. #line 169 "bison.simple"
  949. int
  950. yyparse()
  951. {
  952.   register int yystate;
  953.   register int yyn;
  954.   register short *yyssp;
  955.   register YYSTYPE *yyvsp;
  956.   int yyerrstatus;    /*  number of tokens to shift before error messages enabled */
  957.   int yychar1;        /*  lookahead token as an internal (translated) token number */
  958.  
  959.   short    yyssa[YYINITDEPTH];    /*  the state stack            */
  960.   YYSTYPE yyvsa[YYINITDEPTH];    /*  the semantic value stack        */
  961.  
  962.   short *yyss = yyssa;        /*  refer to the stacks thru separate pointers */
  963.   YYSTYPE *yyvs = yyvsa;    /*  to allow yyoverflow to reallocate them elsewhere */
  964.  
  965. #ifdef YYLSP_NEEDED
  966.   YYLTYPE yylsa[YYINITDEPTH];    /*  the location stack            */
  967.   YYLTYPE *yyls = yylsa;
  968.   YYLTYPE *yylsp;
  969.  
  970. #define YYPOPSTACK   (yyvsp--, yysp--, yylsp--)
  971. #else
  972. #define YYPOPSTACK   (yyvsp--, yysp--)
  973. #endif
  974.  
  975.   int yystacksize = YYINITDEPTH;
  976.  
  977. #ifdef YYPURE
  978.   int yychar;
  979.   YYSTYPE yylval;
  980.   int yynerrs;
  981. #ifdef YYLSP_NEEDED
  982.   YYLTYPE yylloc;
  983. #endif
  984. #endif
  985.  
  986.   YYSTYPE yyval;        /*  the variable used to return        */
  987.                 /*  semantic values from the action    */
  988.                 /*  routines                */
  989.  
  990.   int yylen;
  991.  
  992. #if YYDEBUG != 0
  993.   if (yydebug)
  994.     fprintf(stderr, "Starting parse\n");
  995. #endif
  996.  
  997.   yystate = 0;
  998.   yyerrstatus = 0;
  999.   yynerrs = 0;
  1000.   yychar = YYEMPTY;        /* Cause a token to be read.  */
  1001.  
  1002.   /* Initialize stack pointers.
  1003.      Waste one element of value and location stack
  1004.      so that they stay on the same level as the state stack.  */
  1005.  
  1006.   yyssp = yyss - 1;
  1007.   yyvsp = yyvs;
  1008. #ifdef YYLSP_NEEDED
  1009.   yylsp = yyls;
  1010. #endif
  1011.  
  1012. /* Push a new state, which is found in  yystate  .  */
  1013. /* In all cases, when you get here, the value and location stacks
  1014.    have just been pushed. so pushing a state here evens the stacks.  */
  1015. yynewstate:
  1016.  
  1017.   *++yyssp = yystate;
  1018.  
  1019.   if (yyssp >= yyss + yystacksize - 1)
  1020.     {
  1021.       /* Give user a chance to reallocate the stack */
  1022.       /* Use copies of these so that the &'s don't force the real ones into memory. */
  1023.       YYSTYPE *yyvs1 = yyvs;
  1024.       short *yyss1 = yyss;
  1025. #ifdef YYLSP_NEEDED
  1026.       YYLTYPE *yyls1 = yyls;
  1027. #endif
  1028.  
  1029.       /* Get the current used size of the three stacks, in elements.  */
  1030.       int size = yyssp - yyss + 1;
  1031.  
  1032. #ifdef yyoverflow
  1033.       /* Each stack pointer address is followed by the size of
  1034.      the data in use in that stack, in bytes.  */
  1035.       yyoverflow("parser stack overflow",
  1036.          &yyss1, size * sizeof (*yyssp),
  1037.          &yyvs1, size * sizeof (*yyvsp),
  1038. #ifdef YYLSP_NEEDED
  1039.          &yyls1, size * sizeof (*yylsp),
  1040. #endif
  1041.          &yystacksize);
  1042.  
  1043.       yyss = yyss1; yyvs = yyvs1;
  1044. #ifdef YYLSP_NEEDED
  1045.       yyls = yyls1;
  1046. #endif
  1047. #else /* no yyoverflow */
  1048.       /* Extend the stack our own way.  */
  1049.       if (yystacksize >= YYMAXDEPTH)
  1050.     {
  1051.       yyerror("parser stack overflow");
  1052.       return 2;
  1053.     }
  1054.       yystacksize *= 2;
  1055.       if (yystacksize > YYMAXDEPTH)
  1056.     yystacksize = YYMAXDEPTH;
  1057.       yyss = (short *) alloca (yystacksize * sizeof (*yyssp));
  1058.       __yy_bcopy ((char *)yyss1, (char *)yyss, size * sizeof (*yyssp));
  1059.       yyvs = (YYSTYPE *) alloca (yystacksize * sizeof (*yyvsp));
  1060.       __yy_bcopy ((char *)yyvs1, (char *)yyvs, size * sizeof (*yyvsp));
  1061. #ifdef YYLSP_NEEDED
  1062.       yyls = (YYLTYPE *) alloca (yystacksize * sizeof (*yylsp));
  1063.       __yy_bcopy ((char *)yyls1, (char *)yyls, size * sizeof (*yylsp));
  1064. #endif
  1065. #endif /* no yyoverflow */
  1066.  
  1067.       yyssp = yyss + size - 1;
  1068.       yyvsp = yyvs + size - 1;
  1069. #ifdef YYLSP_NEEDED
  1070.       yylsp = yyls + size - 1;
  1071. #endif
  1072.  
  1073. #if YYDEBUG != 0
  1074.       if (yydebug)
  1075.     fprintf(stderr, "Stack size increased to %d\n", yystacksize);
  1076. #endif
  1077.  
  1078.       if (yyssp >= yyss + yystacksize - 1)
  1079.     YYABORT;
  1080.     }
  1081.  
  1082. #if YYDEBUG != 0
  1083.   if (yydebug)
  1084.     fprintf(stderr, "Entering state %d\n", yystate);
  1085. #endif
  1086.  
  1087.  yybackup:
  1088.  
  1089. /* Do appropriate processing given the current state.  */
  1090. /* Read a lookahead token if we need one and don't already have one.  */
  1091. /* yyresume: */
  1092.  
  1093.   /* First try to decide what to do without reference to lookahead token.  */
  1094.  
  1095.   yyn = yypact[yystate];
  1096.   if (yyn == YYFLAG)
  1097.     goto yydefault;
  1098.  
  1099.   /* Not known => get a lookahead token if don't already have one.  */
  1100.  
  1101.   /* yychar is either YYEMPTY or YYEOF
  1102.      or a valid token in external form.  */
  1103.  
  1104.   if (yychar == YYEMPTY)
  1105.     {
  1106. #if YYDEBUG != 0
  1107.       if (yydebug)
  1108.     fprintf(stderr, "Reading a token: ");
  1109. #endif
  1110.       yychar = YYLEX;
  1111.     }
  1112.  
  1113.   /* Convert token to internal form (in yychar1) for indexing tables with */
  1114.  
  1115.   if (yychar <= 0)        /* This means end of input. */
  1116.     {
  1117.       yychar1 = 0;
  1118.       yychar = YYEOF;        /* Don't call YYLEX any more */
  1119.  
  1120. #if YYDEBUG != 0
  1121.       if (yydebug)
  1122.     fprintf(stderr, "Now at end of input.\n");
  1123. #endif
  1124.     }
  1125.   else
  1126.     {
  1127.       yychar1 = YYTRANSLATE(yychar);
  1128.  
  1129. #if YYDEBUG != 0
  1130.       if (yydebug)
  1131.     {
  1132.       fprintf (stderr, "Next token is %d (%s", yychar, yytname[yychar1]);
  1133.       /* Give the individual parser a way to print the precise meaning
  1134.          of a token, for further debugging info.  */
  1135. #ifdef YYPRINT
  1136.       YYPRINT (stderr, yychar, yylval);
  1137. #endif
  1138.       fprintf (stderr, ")\n");
  1139.     }
  1140. #endif
  1141.     }
  1142.  
  1143.   yyn += yychar1;
  1144.   if (yyn < 0 || yyn > YYLAST || yycheck[yyn] != yychar1)
  1145.     goto yydefault;
  1146.  
  1147.   yyn = yytable[yyn];
  1148.  
  1149.   /* yyn is what to do for this token type in this state.
  1150.      Negative => reduce, -yyn is rule number.
  1151.      Positive => shift, yyn is new state.
  1152.        New state is final state => don't bother to shift,
  1153.        just return success.
  1154.      0, or most negative number => error.  */
  1155.  
  1156.   if (yyn < 0)
  1157.     {
  1158.       if (yyn == YYFLAG)
  1159.     goto yyerrlab;
  1160.       yyn = -yyn;
  1161.       goto yyreduce;
  1162.     }
  1163.   else if (yyn == 0)
  1164.     goto yyerrlab;
  1165.  
  1166.   if (yyn == YYFINAL)
  1167.     YYACCEPT;
  1168.  
  1169.   /* Shift the lookahead token.  */
  1170.  
  1171. #if YYDEBUG != 0
  1172.   if (yydebug)
  1173.     fprintf(stderr, "Shifting token %d (%s), ", yychar, yytname[yychar1]);
  1174. #endif
  1175.  
  1176.   /* Discard the token being shifted unless it is eof.  */
  1177.   if (yychar != YYEOF)
  1178.     yychar = YYEMPTY;
  1179.  
  1180.   *++yyvsp = yylval;
  1181. #ifdef YYLSP_NEEDED
  1182.   *++yylsp = yylloc;
  1183. #endif
  1184.  
  1185.   /* count tokens shifted since error; after three, turn off error status.  */
  1186.   if (yyerrstatus) yyerrstatus--;
  1187.  
  1188.   yystate = yyn;
  1189.   goto yynewstate;
  1190.  
  1191. /* Do the default action for the current state.  */
  1192. yydefault:
  1193.  
  1194.   yyn = yydefact[yystate];
  1195.   if (yyn == 0)
  1196.     goto yyerrlab;
  1197.  
  1198. /* Do a reduction.  yyn is the number of a rule to reduce with.  */
  1199. yyreduce:
  1200.   yylen = yyr2[yyn];
  1201.   yyval = yyvsp[1-yylen]; /* implement default value of the action */
  1202.  
  1203. #if YYDEBUG != 0
  1204.   if (yydebug)
  1205.     {
  1206.       int i;
  1207.  
  1208.       fprintf (stderr, "Reducing via rule %d (line %d), ",
  1209.            yyn, yyrline[yyn]);
  1210.  
  1211.       /* Print the symboles being reduced, and their result.  */
  1212.       for (i = yyprhs[yyn]; yyrhs[i] > 0; i++)
  1213.     fprintf (stderr, "%s ", yytname[yyrhs[i]]);
  1214.       fprintf (stderr, " -> %s\n", yytname[yyr1[yyn]]);
  1215.     }
  1216. #endif
  1217.  
  1218.  
  1219.   switch (yyn) {
  1220.  
  1221. case 1:
  1222. #line 137 "awk.y"
  1223. { expression_value = yyvsp[-1].nodeval; ;
  1224.     break;}
  1225. case 2:
  1226. #line 142 "awk.y"
  1227.             if (yyvsp[0].nodeval != NULL)
  1228.                 yyval.nodeval = yyvsp[0].nodeval;
  1229.             else
  1230.                 yyval.nodeval = NULL;
  1231.             yyerrok;
  1232.         ;
  1233.     break;}
  1234. case 3:
  1235. #line 151 "awk.y"
  1236. {
  1237.             if (yyvsp[0].nodeval == NULL)
  1238.                 yyval.nodeval = yyvsp[-1].nodeval;
  1239.             else if (yyvsp[-1].nodeval == NULL)
  1240.                 yyval.nodeval = yyvsp[0].nodeval;
  1241.             else {
  1242.                 if (yyvsp[-1].nodeval->type != Node_rule_list)
  1243.                     yyvsp[-1].nodeval = node(yyvsp[-1].nodeval, Node_rule_list,
  1244.                         (NODE*)NULL);
  1245.                 yyval.nodeval = append_right (yyvsp[-1].nodeval,
  1246.                    node(yyvsp[0].nodeval, Node_rule_list,(NODE *) NULL));
  1247.             }
  1248.             yyerrok;
  1249.         ;
  1250.     break;}
  1251. case 4:
  1252. #line 165 "awk.y"
  1253. { yyval.nodeval = NULL; ;
  1254.     break;}
  1255. case 5:
  1256. #line 166 "awk.y"
  1257. { yyval.nodeval = NULL; ;
  1258.     break;}
  1259. case 6:
  1260. #line 170 "awk.y"
  1261. { io_allowed = 0; ;
  1262.     break;}
  1263. case 7:
  1264. #line 172 "awk.y"
  1265. {
  1266.         if (begin_block) {
  1267.             if (begin_block->type != Node_rule_list)
  1268.                 begin_block = node(begin_block, Node_rule_list,
  1269.                     (NODE *)NULL);
  1270.             (void) append_right (begin_block, node(
  1271.                 node((NODE *)NULL, Node_rule_node, yyvsp[0].nodeval),
  1272.                 Node_rule_list, (NODE *)NULL) );
  1273.         } else
  1274.             begin_block = node((NODE *)NULL, Node_rule_node, yyvsp[0].nodeval);
  1275.         yyval.nodeval = NULL;
  1276.         io_allowed = 1;
  1277.         yyerrok;
  1278.       ;
  1279.     break;}
  1280. case 8:
  1281. #line 186 "awk.y"
  1282. { io_allowed = 0; ;
  1283.     break;}
  1284. case 9:
  1285. #line 188 "awk.y"
  1286. {
  1287.         if (end_block) {
  1288.             if (end_block->type != Node_rule_list)
  1289.                 end_block = node(end_block, Node_rule_list,
  1290.                     (NODE *)NULL);
  1291.             (void) append_right (end_block, node(
  1292.                 node((NODE *)NULL, Node_rule_node, yyvsp[0].nodeval),
  1293.                 Node_rule_list, (NODE *)NULL));
  1294.         } else
  1295.             end_block = node((NODE *)NULL, Node_rule_node, yyvsp[0].nodeval);
  1296.         yyval.nodeval = NULL;
  1297.         io_allowed = 1;
  1298.         yyerrok;
  1299.       ;
  1300.     break;}
  1301. case 10:
  1302. #line 203 "awk.y"
  1303. {
  1304.         warning("BEGIN blocks must have an action part");
  1305.         errcount++;
  1306.         yyerrok;
  1307.       ;
  1308.     break;}
  1309. case 11:
  1310. #line 209 "awk.y"
  1311. {
  1312.         warning("END blocks must have an action part");
  1313.         errcount++;
  1314.         yyerrok;
  1315.       ;
  1316.     break;}
  1317. case 12:
  1318. #line 215 "awk.y"
  1319. { yyval.nodeval = node (yyvsp[-1].nodeval, Node_rule_node, yyvsp[0].nodeval); yyerrok; ;
  1320.     break;}
  1321. case 13:
  1322. #line 217 "awk.y"
  1323. { yyval.nodeval = node ((NODE *)NULL, Node_rule_node, yyvsp[0].nodeval); yyerrok; ;
  1324.     break;}
  1325. case 14:
  1326. #line 219 "awk.y"
  1327. {
  1328.           yyval.nodeval = node (yyvsp[-1].nodeval,
  1329.                  Node_rule_node,
  1330.                  node(node(node(make_number(0.0),
  1331.                         Node_field_spec,
  1332.                         (NODE *) NULL),
  1333.                     Node_expression_list,
  1334.                     (NODE *) NULL),
  1335.                   Node_K_print,
  1336.                   (NODE *) NULL));
  1337.           yyerrok;
  1338.         ;
  1339.     break;}
  1340. case 15:
  1341. #line 232 "awk.y"
  1342. {
  1343.             func_install(yyvsp[-1].nodeval, yyvsp[0].nodeval);
  1344.             yyval.nodeval = NULL;
  1345.             yyerrok;
  1346.         ;
  1347.     break;}
  1348. case 16:
  1349. #line 241 "awk.y"
  1350. { yyval.sval = yyvsp[0].sval; ;
  1351.     break;}
  1352. case 17:
  1353. #line 243 "awk.y"
  1354. { yyval.sval = yyvsp[0].sval; ;
  1355.     break;}
  1356. case 18:
  1357. #line 245 "awk.y"
  1358. {
  1359.         yyerror("%s() is a built-in function, it cannot be redefined",
  1360.             tokstart);
  1361.         errcount++;
  1362.         /* yyerrok; */
  1363.       ;
  1364.     break;}
  1365. case 21:
  1366. #line 260 "awk.y"
  1367. {
  1368.             param_counter = 0;
  1369.         ;
  1370.     break;}
  1371. case 22:
  1372. #line 264 "awk.y"
  1373. {
  1374.             yyval.nodeval = append_right(make_param(yyvsp[-4].sval), yyvsp[-2].nodeval);
  1375.             can_return = 1;
  1376.         ;
  1377.     break;}
  1378. case 23:
  1379. #line 272 "awk.y"
  1380. {
  1381.         yyval.nodeval = yyvsp[-2].nodeval;
  1382.         can_return = 0;
  1383.       ;
  1384.     break;}
  1385. case 24:
  1386. #line 281 "awk.y"
  1387. { yyval.nodeval = yyvsp[0].nodeval; ;
  1388.     break;}
  1389. case 25:
  1390. #line 283 "awk.y"
  1391. { yyval.nodeval = mkrangenode ( node(yyvsp[-2].nodeval, Node_cond_pair, yyvsp[0].nodeval) ); ;
  1392.     break;}
  1393. case 26:
  1394. #line 292 "awk.y"
  1395. { ++want_regexp; ;
  1396.     break;}
  1397. case 27:
  1398. #line 294 "awk.y"
  1399. {
  1400.           NODE *n;
  1401.  
  1402.           getnode(n);
  1403.           n->type = Node_regex;
  1404.           n->re_exp = make_string(yyvsp[-1].sval, strlen(yyvsp[-1].sval));
  1405.           n->re_reg = mk_re_parse(yyvsp[-1].sval, 0);
  1406.           n->re_text = NULL;
  1407.           n->re_flags = GCONST;
  1408.           n->re_cnt = 1;
  1409.           yyval.nodeval = n;
  1410.         ;
  1411.     break;}
  1412. case 28:
  1413. #line 310 "awk.y"
  1414. { yyval.nodeval = yyvsp[-3].nodeval ; ;
  1415.     break;}
  1416. case 29:
  1417. #line 312 "awk.y"
  1418. { yyval.nodeval = NULL; ;
  1419.     break;}
  1420. case 30:
  1421. #line 317 "awk.y"
  1422. { yyval.nodeval = yyvsp[0].nodeval; ;
  1423.     break;}
  1424. case 31:
  1425. #line 319 "awk.y"
  1426. {
  1427.             if (yyvsp[-1].nodeval == NULL || yyvsp[-1].nodeval->type != Node_statement_list)
  1428.                 yyvsp[-1].nodeval = node(yyvsp[-1].nodeval, Node_statement_list,(NODE *)NULL);
  1429.                 yyval.nodeval = append_right(yyvsp[-1].nodeval,
  1430.                 node( yyvsp[0].nodeval, Node_statement_list, (NODE *)NULL));
  1431.                 yyerrok;
  1432.         ;
  1433.     break;}
  1434. case 32:
  1435. #line 327 "awk.y"
  1436. { yyval.nodeval = NULL; ;
  1437.     break;}
  1438. case 33:
  1439. #line 329 "awk.y"
  1440. { yyval.nodeval = NULL; ;
  1441.     break;}
  1442. case 36:
  1443. #line 339 "awk.y"
  1444. { yyval.nodeval = NULL; ;
  1445.     break;}
  1446. case 37:
  1447. #line 341 "awk.y"
  1448. { yyval.nodeval = NULL; ;
  1449.     break;}
  1450. case 38:
  1451. #line 343 "awk.y"
  1452. { yyval.nodeval = yyvsp[-1].nodeval; ;
  1453.     break;}
  1454. case 39:
  1455. #line 345 "awk.y"
  1456. { yyval.nodeval = yyvsp[0].nodeval; ;
  1457.     break;}
  1458. case 40:
  1459. #line 347 "awk.y"
  1460. { yyval.nodeval = node (yyvsp[-3].nodeval, Node_K_while, yyvsp[0].nodeval); ;
  1461.     break;}
  1462. case 41:
  1463. #line 349 "awk.y"
  1464. { yyval.nodeval = node (yyvsp[-2].nodeval, Node_K_do, yyvsp[-5].nodeval); ;
  1465.     break;}
  1466. case 42:
  1467. #line 351 "awk.y"
  1468. {
  1469.         yyval.nodeval = node (yyvsp[0].nodeval, Node_K_arrayfor, make_for_loop(variable(yyvsp[-5].sval,1),
  1470.             (NODE *)NULL, variable(yyvsp[-3].sval,1)));
  1471.       ;
  1472.     break;}
  1473. case 43:
  1474. #line 356 "awk.y"
  1475. {
  1476.         yyval.nodeval = node(yyvsp[0].nodeval, Node_K_for, (NODE *)make_for_loop(yyvsp[-7].nodeval, yyvsp[-5].nodeval, yyvsp[-3].nodeval));
  1477.       ;
  1478.     break;}
  1479. case 44:
  1480. #line 360 "awk.y"
  1481. {
  1482.         yyval.nodeval = node (yyvsp[0].nodeval, Node_K_for,
  1483.             (NODE *)make_for_loop(yyvsp[-6].nodeval, (NODE *)NULL, yyvsp[-3].nodeval));
  1484.       ;
  1485.     break;}
  1486. case 45:
  1487. #line 366 "awk.y"
  1488. { yyval.nodeval = node ((NODE *)NULL, Node_K_break, (NODE *)NULL); ;
  1489.     break;}
  1490. case 46:
  1491. #line 369 "awk.y"
  1492. { yyval.nodeval = node ((NODE *)NULL, Node_K_continue, (NODE *)NULL); ;
  1493.     break;}
  1494. case 47:
  1495. #line 371 "awk.y"
  1496. { yyval.nodeval = node (yyvsp[-3].nodeval, yyvsp[-5].nodetypeval, yyvsp[-1].nodeval); ;
  1497.     break;}
  1498. case 48:
  1499. #line 373 "awk.y"
  1500. {
  1501.             if (yyvsp[-3].nodetypeval == Node_K_print && yyvsp[-2].nodeval == NULL)
  1502.                 yyvsp[-2].nodeval = node(node(make_number(0.0),
  1503.                            Node_field_spec,
  1504.                            (NODE *) NULL),
  1505.                       Node_expression_list,
  1506.                       (NODE *) NULL);
  1507.  
  1508.             yyval.nodeval = node (yyvsp[-2].nodeval, yyvsp[-3].nodetypeval, yyvsp[-1].nodeval);
  1509.         ;
  1510.     break;}
  1511. case 49:
  1512. #line 384 "awk.y"
  1513. { NODETYPE type;
  1514.  
  1515.           if (! io_allowed) yyerror("next used in BEGIN or END action");
  1516.           if (yyvsp[-1].nodeval && yyvsp[-1].nodeval == lookup("file")) {
  1517.             if (do_lint)
  1518.                 warning("`next file' is a gawk extension");
  1519.             else if (strict || do_posix)
  1520.                 yyerror("`next file' is a gawk extension");
  1521.             type = Node_K_nextfile;
  1522.           } else type = Node_K_next;
  1523.           yyval.nodeval = node ((NODE *)NULL, type, (NODE *)NULL);
  1524.         ;
  1525.     break;}
  1526. case 50:
  1527. #line 397 "awk.y"
  1528. { yyval.nodeval = node (yyvsp[-1].nodeval, Node_K_exit, (NODE *)NULL); ;
  1529.     break;}
  1530. case 51:
  1531. #line 399 "awk.y"
  1532. { if (! can_return) yyerror("return used outside function context"); ;
  1533.     break;}
  1534. case 52:
  1535. #line 401 "awk.y"
  1536. { yyval.nodeval = node (yyvsp[-1].nodeval, Node_K_return, (NODE *)NULL); ;
  1537.     break;}
  1538. case 53:
  1539. #line 403 "awk.y"
  1540. { yyval.nodeval = node (variable(yyvsp[-4].sval,1), Node_K_delete, yyvsp[-2].nodeval); ;
  1541.     break;}
  1542. case 54:
  1543. #line 405 "awk.y"
  1544. { yyval.nodeval = yyvsp[-1].nodeval; ;
  1545.     break;}
  1546. case 55:
  1547. #line 410 "awk.y"
  1548. { yyval.nodetypeval = yyvsp[0].nodetypeval; ;
  1549.     break;}
  1550. case 56:
  1551. #line 412 "awk.y"
  1552. { yyval.nodetypeval = yyvsp[0].nodetypeval; ;
  1553.     break;}
  1554. case 57:
  1555. #line 417 "awk.y"
  1556. {
  1557.         yyval.nodeval = node(yyvsp[-3].nodeval, Node_K_if, 
  1558.             node(yyvsp[0].nodeval, Node_if_branches, (NODE *)NULL));
  1559.       ;
  1560.     break;}
  1561. case 58:
  1562. #line 423 "awk.y"
  1563. { yyval.nodeval = node (yyvsp[-6].nodeval, Node_K_if,
  1564.                 node (yyvsp[-3].nodeval, Node_if_branches, yyvsp[0].nodeval)); ;
  1565.     break;}
  1566. case 59:
  1567. #line 429 "awk.y"
  1568. { want_assign = 0; ;
  1569.     break;}
  1570. case 63:
  1571. #line 440 "awk.y"
  1572. { yyval.nodeval = NULL; ;
  1573.     break;}
  1574. case 64:
  1575. #line 442 "awk.y"
  1576. { yyval.nodeval = node (yyvsp[0].nodeval, Node_redirect_input, (NODE *)NULL); ;
  1577.     break;}
  1578. case 65:
  1579. #line 447 "awk.y"
  1580. { yyval.nodeval = NULL; ;
  1581.     break;}
  1582. case 66:
  1583. #line 449 "awk.y"
  1584. { yyval.nodeval = node (yyvsp[0].nodeval, Node_redirect_output, (NODE *)NULL); ;
  1585.     break;}
  1586. case 67:
  1587. #line 451 "awk.y"
  1588. { yyval.nodeval = node (yyvsp[0].nodeval, Node_redirect_append, (NODE *)NULL); ;
  1589.     break;}
  1590. case 68:
  1591. #line 453 "awk.y"
  1592. { yyval.nodeval = node (yyvsp[0].nodeval, Node_redirect_pipe, (NODE *)NULL); ;
  1593.     break;}
  1594. case 69:
  1595. #line 458 "awk.y"
  1596. { yyval.nodeval = NULL; ;
  1597.     break;}
  1598. case 70:
  1599. #line 460 "awk.y"
  1600. { yyval.nodeval = yyvsp[0].nodeval; ;
  1601.     break;}
  1602. case 71:
  1603. #line 465 "awk.y"
  1604. { yyval.nodeval = make_param(yyvsp[0].sval); ;
  1605.     break;}
  1606. case 72:
  1607. #line 467 "awk.y"
  1608. { yyval.nodeval = append_right(yyvsp[-2].nodeval, make_param(yyvsp[0].sval)); yyerrok; ;
  1609.     break;}
  1610. case 73:
  1611. #line 469 "awk.y"
  1612. { yyval.nodeval = NULL; ;
  1613.     break;}
  1614. case 74:
  1615. #line 471 "awk.y"
  1616. { yyval.nodeval = NULL; ;
  1617.     break;}
  1618. case 75:
  1619. #line 473 "awk.y"
  1620. { yyval.nodeval = NULL; ;
  1621.     break;}
  1622. case 76:
  1623. #line 479 "awk.y"
  1624. { yyval.nodeval = NULL; ;
  1625.     break;}
  1626. case 77:
  1627. #line 481 "awk.y"
  1628. { yyval.nodeval = yyvsp[0].nodeval; ;
  1629.     break;}
  1630. case 78:
  1631. #line 486 "awk.y"
  1632. { yyval.nodeval = NULL; ;
  1633.     break;}
  1634. case 79:
  1635. #line 488 "awk.y"
  1636. { yyval.nodeval = yyvsp[0].nodeval; ;
  1637.     break;}
  1638. case 80:
  1639. #line 493 "awk.y"
  1640. { yyval.nodeval = node (yyvsp[0].nodeval, Node_expression_list, (NODE *)NULL); ;
  1641.     break;}
  1642. case 81:
  1643. #line 495 "awk.y"
  1644. {
  1645.         yyval.nodeval = append_right(yyvsp[-2].nodeval,
  1646.             node( yyvsp[0].nodeval, Node_expression_list, (NODE *)NULL));
  1647.         yyerrok;
  1648.       ;
  1649.     break;}
  1650. case 82:
  1651. #line 501 "awk.y"
  1652. { yyval.nodeval = NULL; ;
  1653.     break;}
  1654. case 83:
  1655. #line 503 "awk.y"
  1656. { yyval.nodeval = NULL; ;
  1657.     break;}
  1658. case 84:
  1659. #line 505 "awk.y"
  1660. { yyval.nodeval = NULL; ;
  1661.     break;}
  1662. case 85:
  1663. #line 507 "awk.y"
  1664. { yyval.nodeval = NULL; ;
  1665.     break;}
  1666. case 86:
  1667. #line 512 "awk.y"
  1668. { yyval.nodeval = NULL; ;
  1669.     break;}
  1670. case 87:
  1671. #line 514 "awk.y"
  1672. { yyval.nodeval = yyvsp[0].nodeval; ;
  1673.     break;}
  1674. case 88:
  1675. #line 519 "awk.y"
  1676. { yyval.nodeval = node (yyvsp[0].nodeval, Node_expression_list, (NODE *)NULL); ;
  1677.     break;}
  1678. case 89:
  1679. #line 521 "awk.y"
  1680. {
  1681.             yyval.nodeval = append_right(yyvsp[-2].nodeval,
  1682.                 node( yyvsp[0].nodeval, Node_expression_list, (NODE *)NULL));
  1683.             yyerrok;
  1684.         ;
  1685.     break;}
  1686. case 90:
  1687. #line 527 "awk.y"
  1688. { yyval.nodeval = NULL; ;
  1689.     break;}
  1690. case 91:
  1691. #line 529 "awk.y"
  1692. { yyval.nodeval = NULL; ;
  1693.     break;}
  1694. case 92:
  1695. #line 531 "awk.y"
  1696. { yyval.nodeval = NULL; ;
  1697.     break;}
  1698. case 93:
  1699. #line 533 "awk.y"
  1700. { yyval.nodeval = NULL; ;
  1701.     break;}
  1702. case 94:
  1703. #line 538 "awk.y"
  1704. { want_assign = 0; ;
  1705.     break;}
  1706. case 95:
  1707. #line 540 "awk.y"
  1708. {
  1709.           if (do_lint && yyvsp[0].nodeval->type == Node_regex)
  1710.             warning("Regular expression on left of assignment.");
  1711.           yyval.nodeval = node (yyvsp[-3].nodeval, yyvsp[-2].nodetypeval, yyvsp[0].nodeval);
  1712.         ;
  1713.     break;}
  1714. case 96:
  1715. #line 546 "awk.y"
  1716. { yyval.nodeval = node (variable(yyvsp[0].sval,1), Node_in_array, yyvsp[-3].nodeval); ;
  1717.     break;}
  1718. case 97:
  1719. #line 548 "awk.y"
  1720. {
  1721.           yyval.nodeval = node (yyvsp[0].nodeval, Node_K_getline,
  1722.              node (yyvsp[-3].nodeval, Node_redirect_pipein, (NODE *)NULL));
  1723.         ;
  1724.     break;}
  1725. case 98:
  1726. #line 553 "awk.y"
  1727. {
  1728.           if (do_lint && ! io_allowed && yyvsp[0].nodeval == NULL)
  1729.             warning("non-redirected getline undefined inside BEGIN or END action");
  1730.           yyval.nodeval = node (yyvsp[-1].nodeval, Node_K_getline, yyvsp[0].nodeval);
  1731.         ;
  1732.     break;}
  1733. case 99:
  1734. #line 559 "awk.y"
  1735. { yyval.nodeval = node (yyvsp[-2].nodeval, Node_and, yyvsp[0].nodeval); ;
  1736.     break;}
  1737. case 100:
  1738. #line 561 "awk.y"
  1739. { yyval.nodeval = node (yyvsp[-2].nodeval, Node_or, yyvsp[0].nodeval); ;
  1740.     break;}
  1741. case 101:
  1742. #line 563 "awk.y"
  1743. {
  1744.           if (yyvsp[-2].nodeval->type == Node_regex)
  1745.             warning("Regular expression on left of MATCH operator.");
  1746.           yyval.nodeval = node (yyvsp[-2].nodeval, yyvsp[-1].nodetypeval, mk_rexp(yyvsp[0].nodeval));
  1747.         ;
  1748.     break;}
  1749. case 102:
  1750. #line 569 "awk.y"
  1751. { yyval.nodeval = yyvsp[0].nodeval; ;
  1752.     break;}
  1753. case 103:
  1754. #line 571 "awk.y"
  1755. {
  1756.           yyval.nodeval = node(node(make_number(0.0),
  1757.                  Node_field_spec,
  1758.                  (NODE *) NULL),
  1759.                     Node_nomatch,
  1760.                 yyvsp[0].nodeval);
  1761.         ;
  1762.     break;}
  1763. case 104:
  1764. #line 579 "awk.y"
  1765. { yyval.nodeval = node (variable(yyvsp[0].sval,1), Node_in_array, yyvsp[-2].nodeval); ;
  1766.     break;}
  1767. case 105:
  1768. #line 581 "awk.y"
  1769. {
  1770.           if (do_lint && yyvsp[0].nodeval->type == Node_regex)
  1771.             warning("Regular expression on left of comparison.");
  1772.           yyval.nodeval = node (yyvsp[-2].nodeval, yyvsp[-1].nodetypeval, yyvsp[0].nodeval);
  1773.         ;
  1774.     break;}
  1775. case 106:
  1776. #line 587 "awk.y"
  1777. { yyval.nodeval = node (yyvsp[-2].nodeval, Node_less, yyvsp[0].nodeval); ;
  1778.     break;}
  1779. case 107:
  1780. #line 589 "awk.y"
  1781. { yyval.nodeval = node (yyvsp[-2].nodeval, Node_greater, yyvsp[0].nodeval); ;
  1782.     break;}
  1783. case 108:
  1784. #line 591 "awk.y"
  1785. { yyval.nodeval = node(yyvsp[-4].nodeval, Node_cond_exp, node(yyvsp[-2].nodeval, Node_if_branches, yyvsp[0].nodeval));;
  1786.     break;}
  1787. case 109:
  1788. #line 593 "awk.y"
  1789. { yyval.nodeval = yyvsp[0].nodeval; ;
  1790.     break;}
  1791. case 110:
  1792. #line 595 "awk.y"
  1793. { yyval.nodeval = node (yyvsp[-1].nodeval, Node_concat, yyvsp[0].nodeval); ;
  1794.     break;}
  1795. case 111:
  1796. #line 600 "awk.y"
  1797. { want_assign = 0; ;
  1798.     break;}
  1799. case 112:
  1800. #line 602 "awk.y"
  1801. { yyval.nodeval = node (yyvsp[-3].nodeval, yyvsp[-2].nodetypeval, yyvsp[0].nodeval); ;
  1802.     break;}
  1803. case 113:
  1804. #line 604 "awk.y"
  1805. { yyval.nodeval = node (yyvsp[-2].nodeval, Node_and, yyvsp[0].nodeval); ;
  1806.     break;}
  1807. case 114:
  1808. #line 606 "awk.y"
  1809. { yyval.nodeval = node (yyvsp[-2].nodeval, Node_or, yyvsp[0].nodeval); ;
  1810.     break;}
  1811. case 115:
  1812. #line 608 "awk.y"
  1813. {
  1814.           if (do_lint && ! io_allowed && yyvsp[0].nodeval == NULL)
  1815.             warning("non-redirected getline undefined inside BEGIN or END action");
  1816.           yyval.nodeval = node (yyvsp[-1].nodeval, Node_K_getline, yyvsp[0].nodeval);
  1817.         ;
  1818.     break;}
  1819. case 116:
  1820. #line 614 "awk.y"
  1821. { yyval.nodeval = yyvsp[0].nodeval; ;
  1822.     break;}
  1823. case 117:
  1824. #line 616 "awk.y"
  1825. { yyval.nodeval = node((NODE *) NULL, Node_nomatch, yyvsp[0].nodeval); ;
  1826.     break;}
  1827. case 118:
  1828. #line 618 "awk.y"
  1829. { yyval.nodeval = node (yyvsp[-2].nodeval, yyvsp[-1].nodetypeval, mk_rexp(yyvsp[0].nodeval)); ;
  1830.     break;}
  1831. case 119:
  1832. #line 620 "awk.y"
  1833. { yyval.nodeval = node (variable(yyvsp[0].sval,1), Node_in_array, yyvsp[-2].nodeval); ;
  1834.     break;}
  1835. case 120:
  1836. #line 622 "awk.y"
  1837. { yyval.nodeval = node (yyvsp[-2].nodeval, yyvsp[-1].nodetypeval, yyvsp[0].nodeval); ;
  1838.     break;}
  1839. case 121:
  1840. #line 624 "awk.y"
  1841. { yyval.nodeval = node(yyvsp[-4].nodeval, Node_cond_exp, node(yyvsp[-2].nodeval, Node_if_branches, yyvsp[0].nodeval));;
  1842.     break;}
  1843. case 122:
  1844. #line 626 "awk.y"
  1845. { yyval.nodeval = yyvsp[0].nodeval; ;
  1846.     break;}
  1847. case 123:
  1848. #line 628 "awk.y"
  1849. { yyval.nodeval = node (yyvsp[-1].nodeval, Node_concat, yyvsp[0].nodeval); ;
  1850.     break;}
  1851. case 126:
  1852. #line 636 "awk.y"
  1853. { yyval.nodeval = node (yyvsp[-2].nodeval, Node_exp, yyvsp[0].nodeval); ;
  1854.     break;}
  1855. case 127:
  1856. #line 638 "awk.y"
  1857. { yyval.nodeval = node (yyvsp[-2].nodeval, Node_times, yyvsp[0].nodeval); ;
  1858.     break;}
  1859. case 128:
  1860. #line 640 "awk.y"
  1861. { yyval.nodeval = node (yyvsp[-2].nodeval, Node_quotient, yyvsp[0].nodeval); ;
  1862.     break;}
  1863. case 129:
  1864. #line 642 "awk.y"
  1865. { yyval.nodeval = node (yyvsp[-2].nodeval, Node_mod, yyvsp[0].nodeval); ;
  1866.     break;}
  1867. case 130:
  1868. #line 644 "awk.y"
  1869. { yyval.nodeval = node (yyvsp[-2].nodeval, Node_plus, yyvsp[0].nodeval); ;
  1870.     break;}
  1871. case 131:
  1872. #line 646 "awk.y"
  1873. { yyval.nodeval = node (yyvsp[-2].nodeval, Node_minus, yyvsp[0].nodeval); ;
  1874.     break;}
  1875. case 132:
  1876. #line 651 "awk.y"
  1877. { yyval.nodeval = node (yyvsp[0].nodeval, Node_not,(NODE *) NULL); ;
  1878.     break;}
  1879. case 133:
  1880. #line 653 "awk.y"
  1881. { yyval.nodeval = yyvsp[-1].nodeval; ;
  1882.     break;}
  1883. case 134:
  1884. #line 655 "awk.y"
  1885.         if (! io_allowed && strcmp(tokstart, "nextfile") == 0)
  1886.             yyerror("nextfile() is illegal in BEGIN and END");
  1887.         ;
  1888.     break;}
  1889. case 135:
  1890. #line 660 "awk.y"
  1891. { yyval.nodeval = snode (yyvsp[-1].nodeval, Node_builtin, (int) yyvsp[-4].lval); ;
  1892.     break;}
  1893. case 136:
  1894. #line 662 "awk.y"
  1895. { yyval.nodeval = snode (yyvsp[-1].nodeval, Node_builtin, (int) yyvsp[-3].lval); ;
  1896.     break;}
  1897. case 137:
  1898. #line 664 "awk.y"
  1899. {
  1900.         if (do_lint)
  1901.             warning("call of `length' without parentheses is not portable");
  1902.         yyval.nodeval = snode ((NODE *)NULL, Node_builtin, (int) yyvsp[0].lval);
  1903.         if (do_posix)
  1904.             warning( "call of `length' without parentheses is deprecated by POSIX");
  1905.       ;
  1906.     break;}
  1907. case 138:
  1908. #line 672 "awk.y"
  1909. {
  1910.         yyval.nodeval = node (yyvsp[-1].nodeval, Node_func_call, make_string(yyvsp[-3].sval, strlen(yyvsp[-3].sval)));
  1911.       ;
  1912.     break;}
  1913. case 139:
  1914. #line 676 "awk.y"
  1915. { yyval.nodeval = node (yyvsp[0].nodeval, Node_preincrement, (NODE *)NULL); ;
  1916.     break;}
  1917. case 140:
  1918. #line 678 "awk.y"
  1919. { yyval.nodeval = node (yyvsp[0].nodeval, Node_predecrement, (NODE *)NULL); ;
  1920.     break;}
  1921. case 141:
  1922. #line 680 "awk.y"
  1923. { yyval.nodeval = yyvsp[0].nodeval; ;
  1924.     break;}
  1925. case 142:
  1926. #line 682 "awk.y"
  1927. { yyval.nodeval = yyvsp[0].nodeval; ;
  1928.     break;}
  1929. case 143:
  1930. #line 685 "awk.y"
  1931. { if (yyvsp[0].nodeval->type == Node_val) {
  1932.             yyvsp[0].nodeval->numbr = -(force_number(yyvsp[0].nodeval));
  1933.             yyval.nodeval = yyvsp[0].nodeval;
  1934.           } else
  1935.             yyval.nodeval = node (yyvsp[0].nodeval, Node_unary_minus, (NODE *)NULL);
  1936.         ;
  1937.     break;}
  1938. case 144:
  1939. #line 692 "awk.y"
  1940. { yyval.nodeval = yyvsp[0].nodeval; ;
  1941.     break;}
  1942. case 145:
  1943. #line 697 "awk.y"
  1944. { yyval.nodeval = node (yyvsp[-1].nodeval, Node_postincrement, (NODE *)NULL); ;
  1945.     break;}
  1946. case 146:
  1947. #line 699 "awk.y"
  1948. { yyval.nodeval = node (yyvsp[-1].nodeval, Node_postdecrement, (NODE *)NULL); ;
  1949.     break;}
  1950. case 148:
  1951. #line 705 "awk.y"
  1952. { yyval.nodeval = NULL; ;
  1953.     break;}
  1954. case 149:
  1955. #line 707 "awk.y"
  1956. { yyval.nodeval = yyvsp[0].nodeval; ;
  1957.     break;}
  1958. case 150:
  1959. #line 712 "awk.y"
  1960. { yyval.nodeval = variable(yyvsp[0].sval,1); ;
  1961.     break;}
  1962. case 151:
  1963. #line 714 "awk.y"
  1964. {
  1965.         if (yyvsp[-1].nodeval->rnode == NULL) {
  1966.             yyval.nodeval = node (variable(yyvsp[-3].sval,1), Node_subscript, yyvsp[-1].nodeval->lnode);
  1967.             freenode(yyvsp[-1].nodeval);
  1968.         } else
  1969.             yyval.nodeval = node (variable(yyvsp[-3].sval,1), Node_subscript, yyvsp[-1].nodeval);
  1970.         ;
  1971.     break;}
  1972. case 152:
  1973. #line 722 "awk.y"
  1974. { yyval.nodeval = node (yyvsp[0].nodeval, Node_field_spec, (NODE *)NULL); ;
  1975.     break;}
  1976. case 153:
  1977. #line 724 "awk.y"
  1978. { yyval.nodeval = node (yyvsp[0].nodeval, Node_field_spec, (NODE *)NULL); ;
  1979.     break;}
  1980. case 155:
  1981. #line 732 "awk.y"
  1982. { yyerrok; ;
  1983.     break;}
  1984. case 156:
  1985. #line 736 "awk.y"
  1986. { yyerrok; ;
  1987.     break;}
  1988. case 159:
  1989. #line 745 "awk.y"
  1990. { yyerrok; want_assign = 0; ;
  1991.     break;}
  1992. case 160:
  1993. #line 748 "awk.y"
  1994. { yyerrok; ;
  1995.     break;}
  1996. }
  1997.    /* the action file gets copied in in place of this dollarsign */
  1998. #line 440 "bison.simple"
  1999.  
  2000.   yyvsp -= yylen;
  2001.   yyssp -= yylen;
  2002. #ifdef YYLSP_NEEDED
  2003.   yylsp -= yylen;
  2004. #endif
  2005.  
  2006. #if YYDEBUG != 0
  2007.   if (yydebug)
  2008.     {
  2009.       short *ssp1 = yyss - 1;
  2010.       fprintf (stderr, "state stack now");
  2011.       while (ssp1 != yyssp)
  2012.     fprintf (stderr, " %d", *++ssp1);
  2013.       fprintf (stderr, "\n");
  2014.     }
  2015. #endif
  2016.  
  2017.   *++yyvsp = yyval;
  2018.  
  2019. #ifdef YYLSP_NEEDED
  2020.   yylsp++;
  2021.   if (yylen == 0)
  2022.     {
  2023.       yylsp->first_line = yylloc.first_line;
  2024.       yylsp->first_column = yylloc.first_column;
  2025.       yylsp->last_line = (yylsp-1)->last_line;
  2026.       yylsp->last_column = (yylsp-1)->last_column;
  2027.       yylsp->text = 0;
  2028.     }
  2029.   else
  2030.     {
  2031.       yylsp->last_line = (yylsp+yylen-1)->last_line;
  2032.       yylsp->last_column = (yylsp+yylen-1)->last_column;
  2033.     }
  2034. #endif
  2035.  
  2036.   /* Now "shift" the result of the reduction.
  2037.      Determine what state that goes to,
  2038.      based on the state we popped back to
  2039.      and the rule number reduced by.  */
  2040.  
  2041.   yyn = yyr1[yyn];
  2042.  
  2043.   yystate = yypgoto[yyn - YYNTBASE] + *yyssp;
  2044.   if (yystate >= 0 && yystate <= YYLAST && yycheck[yystate] == *yyssp)
  2045.     yystate = yytable[yystate];
  2046.   else
  2047.     yystate = yydefgoto[yyn - YYNTBASE];
  2048.  
  2049.   goto yynewstate;
  2050.  
  2051. yyerrlab:   /* here on detecting error */
  2052.  
  2053.   if (! yyerrstatus)
  2054.     /* If not already recovering from an error, report this error.  */
  2055.     {
  2056.       ++yynerrs;
  2057.  
  2058. #ifdef YYERROR_VERBOSE
  2059.       yyn = yypact[yystate];
  2060.  
  2061.       if (yyn > YYFLAG && yyn < YYLAST)
  2062.     {
  2063.       int size = 0;
  2064.       char *msg;
  2065.       int x, count;
  2066.  
  2067.       count = 0;
  2068.       for (x = 0; x < (sizeof(yytname) / sizeof(char *)); x++)
  2069.         if (yycheck[x + yyn] == x)
  2070.           size += strlen(yytname[x]) + 15, count++;
  2071.       msg = (char *) xmalloc(size + 15);
  2072.       strcpy(msg, "parse error");
  2073.  
  2074.       if (count < 5)
  2075.         {
  2076.           count = 0;
  2077.           for (x = 0; x < (sizeof(yytname) / sizeof(char *)); x++)
  2078.         if (yycheck[x + yyn] == x)
  2079.           {
  2080.             strcat(msg, count == 0 ? ", expecting `" : " or `");
  2081.             strcat(msg, yytname[x]);
  2082.             strcat(msg, "'");
  2083.             count++;
  2084.           }
  2085.         }
  2086.       yyerror(msg);
  2087.       free(msg);
  2088.     }
  2089.       else
  2090. #endif /* YYERROR_VERBOSE */
  2091.     yyerror("parse error");
  2092.     }
  2093.  
  2094. yyerrlab1:   /* here on error raised explicitly by an action */
  2095.  
  2096.   if (yyerrstatus == 3)
  2097.     {
  2098.       /* if just tried and failed to reuse lookahead token after an error, discard it.  */
  2099.  
  2100.       /* return failure if at end of input */
  2101.       if (yychar == YYEOF)
  2102.     YYABORT;
  2103.  
  2104. #if YYDEBUG != 0
  2105.       if (yydebug)
  2106.     fprintf(stderr, "Discarding token %d (%s).\n", yychar, yytname[yychar1]);
  2107. #endif
  2108.  
  2109.       yychar = YYEMPTY;
  2110.     }
  2111.  
  2112.   /* Else will try to reuse lookahead token
  2113.      after shifting the error token.  */
  2114.  
  2115.   yyerrstatus = 3;        /* Each real token shifted decrements this */
  2116.  
  2117.   goto yyerrhandle;
  2118.  
  2119. yyerrdefault:  /* current state does not do anything special for the error token. */
  2120.  
  2121. #if 0
  2122.   /* This is wrong; only states that explicitly want error tokens
  2123.      should shift them.  */
  2124.   yyn = yydefact[yystate];  /* If its default is to accept any token, ok.  Otherwise pop it.*/
  2125.   if (yyn) goto yydefault;
  2126. #endif
  2127.  
  2128. yyerrpop:   /* pop the current state because it cannot handle the error token */
  2129.  
  2130.   if (yyssp == yyss) YYABORT;
  2131.   yyvsp--;
  2132.   yystate = *--yyssp;
  2133. #ifdef YYLSP_NEEDED
  2134.   yylsp--;
  2135. #endif
  2136.  
  2137. #if YYDEBUG != 0
  2138.   if (yydebug)
  2139.     {
  2140.       short *ssp1 = yyss - 1;
  2141.       fprintf (stderr, "Error: state stack now");
  2142.       while (ssp1 != yyssp)
  2143.     fprintf (stderr, " %d", *++ssp1);
  2144.       fprintf (stderr, "\n");
  2145.     }
  2146. #endif
  2147.  
  2148. yyerrhandle:
  2149.  
  2150.   yyn = yypact[yystate];
  2151.   if (yyn == YYFLAG)
  2152.     goto yyerrdefault;
  2153.  
  2154.   yyn += YYTERROR;
  2155.   if (yyn < 0 || yyn > YYLAST || yycheck[yyn] != YYTERROR)
  2156.     goto yyerrdefault;
  2157.  
  2158.   yyn = yytable[yyn];
  2159.   if (yyn < 0)
  2160.     {
  2161.       if (yyn == YYFLAG)
  2162.     goto yyerrpop;
  2163.       yyn = -yyn;
  2164.       goto yyreduce;
  2165.     }
  2166.   else if (yyn == 0)
  2167.     goto yyerrpop;
  2168.  
  2169.   if (yyn == YYFINAL)
  2170.     YYACCEPT;
  2171.  
  2172. #if YYDEBUG != 0
  2173.   if (yydebug)
  2174.     fprintf(stderr, "Shifting error token, ");
  2175. #endif
  2176.  
  2177.   *++yyvsp = yylval;
  2178. #ifdef YYLSP_NEEDED
  2179.   *++yylsp = yylloc;
  2180. #endif
  2181.  
  2182.   yystate = yyn;
  2183.   goto yynewstate;
  2184. }
  2185. #define _INTSIZEOF(n)     ( (sizeof(n) + sizeof(int) - 1) & ~(sizeof(int) - 1) )
  2186.  
  2187. #define va_dcl va_list va_alist;
  2188. #define va_start(ap) ap = (va_list)&va_alist
  2189. #define va_arg(ap,t)    ( *(t *)((ap += _INTSIZEOF(t)) - _INTSIZEOF(t)) )
  2190. #define va_end(ap) ap = (va_list)0
  2191.  
  2192. #line 751 "awk.y"
  2193.  
  2194.  
  2195. struct token {
  2196.     char *operator;        /* text to match */
  2197.     NODETYPE value;        /* node type */
  2198.     int class;        /* lexical class */
  2199.     unsigned flags;        /* # of args. allowed and compatability */
  2200. #    define    ARGS    0xFF    /* 0, 1, 2, 3 args allowed (any combination */
  2201. #    define    A(n)    (1<<(n))
  2202. #    define    VERSION    0xFF00    /* old awk is zero */
  2203. #    define    NOT_OLD        0x0100    /* feature not in old awk */
  2204. #    define    NOT_POSIX    0x0200    /* feature not in POSIX */
  2205. #    define    GAWKX        0x0400    /* gawk extension */
  2206.     NODE *(*ptr) ();    /* function that implements this keyword */
  2207. };
  2208.  
  2209. extern NODE
  2210.     *do_exp(),    *do_getline(),    *do_index(),    *do_length(),
  2211.     *do_sqrt(),    *do_log(),    *do_sprintf(),    *do_substr(),
  2212.     *do_split(),    *do_system(),    *do_int(),    *do_close(),
  2213.     *do_atan2(),    *do_sin(),    *do_cos(),    *do_rand(),
  2214.     *do_srand(),    *do_match(),    *do_tolower(),    *do_toupper(),
  2215.     *do_sub(),    *do_gsub(),    *do_strftime(),    *do_systime();
  2216.  
  2217. /* Tokentab is sorted ascii ascending order, so it can be binary searched. */
  2218.  
  2219. static struct token tokentab[] = {
  2220. {"BEGIN",    Node_illegal,     LEX_BEGIN,    0,        0},
  2221. {"END",        Node_illegal,     LEX_END,    0,        0},
  2222. {"atan2",    Node_builtin,     LEX_BUILTIN,    NOT_OLD|A(2),    do_atan2},
  2223. {"break",    Node_K_break,     LEX_BREAK,    0,        0},
  2224. {"close",    Node_builtin,     LEX_BUILTIN,    NOT_OLD|A(1),    do_close},
  2225. {"continue",    Node_K_continue, LEX_CONTINUE,    0,        0},
  2226. {"cos",        Node_builtin,     LEX_BUILTIN,    NOT_OLD|A(1),    do_cos},
  2227. {"delete",    Node_K_delete,     LEX_DELETE,    NOT_OLD,    0},
  2228. {"do",        Node_K_do,     LEX_DO,    NOT_OLD,    0},
  2229. {"else",    Node_illegal,     LEX_ELSE,    0,        0},
  2230. {"exit",    Node_K_exit,     LEX_EXIT,    0,        0},
  2231. {"exp",        Node_builtin,     LEX_BUILTIN,    A(1),        do_exp},
  2232. {"for",        Node_K_for,     LEX_FOR,    0,        0},
  2233. {"func",    Node_K_function, LEX_FUNCTION,    NOT_POSIX|NOT_OLD,    0},
  2234. {"function",    Node_K_function, LEX_FUNCTION,    NOT_OLD,    0},
  2235. {"getline",    Node_K_getline,     LEX_GETLINE,    NOT_OLD,    0},
  2236. {"gsub",    Node_builtin,     LEX_BUILTIN,    NOT_OLD|A(2)|A(3), do_gsub},
  2237. {"if",        Node_K_if,     LEX_IF,    0,        0},
  2238. {"in",        Node_illegal,     LEX_IN,    0,        0},
  2239. {"index",    Node_builtin,     LEX_BUILTIN,    A(2),        do_index},
  2240. {"int",        Node_builtin,     LEX_BUILTIN,    A(1),        do_int},
  2241. {"length",    Node_builtin,     LEX_LENGTH,    A(0)|A(1),    do_length},
  2242. {"log",        Node_builtin,     LEX_BUILTIN,    A(1),        do_log},
  2243. {"match",    Node_builtin,     LEX_BUILTIN,    NOT_OLD|A(2),    do_match},
  2244. {"next",    Node_K_next,     LEX_NEXT,    0,        0},
  2245. {"print",    Node_K_print,     LEX_PRINT,    0,        0},
  2246. {"printf",    Node_K_printf,     LEX_PRINTF,    0,        0},
  2247. {"rand",    Node_builtin,     LEX_BUILTIN,    NOT_OLD|A(0),    do_rand},
  2248. {"return",    Node_K_return,     LEX_RETURN,    NOT_OLD,    0},
  2249. {"sin",        Node_builtin,     LEX_BUILTIN,    NOT_OLD|A(1),    do_sin},
  2250. {"split",    Node_builtin,     LEX_BUILTIN,    A(2)|A(3),    do_split},
  2251. {"sprintf",    Node_builtin,     LEX_BUILTIN,    0,        do_sprintf},
  2252. {"sqrt",    Node_builtin,     LEX_BUILTIN,    A(1),        do_sqrt},
  2253. {"srand",    Node_builtin,     LEX_BUILTIN,    NOT_OLD|A(0)|A(1), do_srand},
  2254. {"strftime",    Node_builtin,     LEX_BUILTIN,    GAWKX|A(1)|A(2), do_strftime},
  2255. {"sub",        Node_builtin,     LEX_BUILTIN,    NOT_OLD|A(2)|A(3), do_sub},
  2256. {"substr",    Node_builtin,     LEX_BUILTIN,    A(2)|A(3),    do_substr},
  2257. {"system",    Node_builtin,     LEX_BUILTIN,    NOT_OLD|A(1),    do_system},
  2258. {"systime",    Node_builtin,     LEX_BUILTIN,    GAWKX|A(0),    do_systime},
  2259. {"tolower",    Node_builtin,     LEX_BUILTIN,    NOT_OLD|A(1),    do_tolower},
  2260. {"toupper",    Node_builtin,     LEX_BUILTIN,    NOT_OLD|A(1),    do_toupper},
  2261. {"while",    Node_K_while,     LEX_WHILE,    0,        0},
  2262. };
  2263.  
  2264. /* VARARGS0 */
  2265. static void
  2266. yyerror(va_alist)
  2267. va_dcl
  2268. {
  2269.     va_list args;
  2270.     char *mesg;
  2271.     register char *bp, *cp;
  2272.     char *scan;
  2273.     char buf[120];
  2274.  
  2275.     errcount++;
  2276.     /* Find the current line in the input file */
  2277.     if (lexptr) {
  2278.         if (!thisline) {
  2279.             for (cp=lexeme; cp != lexptr_begin && *cp != '\n'; --cp)
  2280.                 ;
  2281.             if (*cp == '\n')
  2282.                 cp++;
  2283.             thisline = cp;
  2284.         }
  2285.         /* NL isn't guaranteed */
  2286.         bp = lexeme;
  2287.         while (bp < lexend && *bp && *bp != '\n')
  2288.             bp++;
  2289.     } else {
  2290.         thisline = "(END OF FILE)";
  2291.         bp = thisline + 13;
  2292.     }
  2293.     msg("%.*s", (int) (bp - thisline), thisline);
  2294.     bp = buf;
  2295.     cp = buf + sizeof(buf) - 24;    /* 24 more than longest msg. input */
  2296.     if (lexptr) {
  2297.         scan = thisline;
  2298.         while (bp < cp && scan < lexeme)
  2299.             if (*scan++ == '\t')
  2300.                 *bp++ = '\t';
  2301.             else
  2302.                 *bp++ = ' ';
  2303.         *bp++ = '^';
  2304.         *bp++ = ' ';
  2305.     }
  2306.     va_start(args);
  2307.     mesg = va_arg(args, char *);
  2308.     strcpy(bp, mesg);
  2309.     err("", buf, args);
  2310.     va_end(args);
  2311.     exit(2);
  2312. }
  2313.  
  2314. static char *
  2315. get_src_buf()
  2316. {
  2317.     static int samefile = 0;
  2318.     static int nextfile = 0;
  2319.     static char *buf = NULL;
  2320.     static int fd;
  2321.     int n;
  2322.     register char *scan;
  2323.     static int len = 0;
  2324.     static int did_newline = 0;
  2325. #    define    SLOP    128    /* enough space to hold most source lines */
  2326.  
  2327.     if (cmdline_src) {
  2328.         if (len == 0) {
  2329.             len = strlen(cmdline_src);
  2330.             if (len == 0)
  2331.                 cmdline_src = NULL;
  2332.             sourceline = 1;
  2333.             lexptr = lexptr_begin = cmdline_src;
  2334.             lexend = lexptr + len;
  2335.         } else if (!did_newline && *(lexptr-1) != '\n') {
  2336.             /*
  2337.              * The following goop is to ensure that the source
  2338.              * ends with a newline and that the entire current
  2339.              * line is available for error messages.
  2340.              */
  2341.             int offset;
  2342.  
  2343.             did_newline = 1;
  2344.             offset = lexptr - lexeme;
  2345.             for (scan = lexeme; scan > lexptr_begin; scan--)
  2346.                 if (*scan == '\n') {
  2347.                     scan++;
  2348.                     break;
  2349.                 }
  2350.             len = lexptr - scan;
  2351.             emalloc(buf, char *, len+1, "get_src_buf");
  2352.             memcpy(buf, scan, len);
  2353.             thisline = buf;
  2354.             lexptr = buf + len;
  2355.             *lexptr = '\n';
  2356.             lexeme = lexptr - offset;
  2357.             lexptr_begin = buf;
  2358.             lexend = lexptr + 1;
  2359.         } else
  2360.             lexeme = lexptr = lexptr_begin = NULL;
  2361.         return lexptr;
  2362.     }
  2363.     if (!samefile) {
  2364.         source = srcfiles[nextfile];
  2365.         if (source == NULL) {
  2366.             if (buf)
  2367.                 free(buf);
  2368.             return lexeme = lexptr = lexptr_begin = NULL;
  2369.         }
  2370.         fd = pathopen(source);
  2371.         if (fd == -1)
  2372.             fatal("can't open source file \"%s\" for reading (%s)",
  2373.                 source, strerror(errno));
  2374.         len = optimal_bufsize(fd);
  2375.         if (buf)
  2376.             free(buf);
  2377.         emalloc(buf, char *, len + SLOP, "get_src_buf");
  2378.         lexptr_begin = buf + SLOP;
  2379.         samefile = 1;
  2380.         sourceline = 1;
  2381.     } else {
  2382.         /*
  2383.          * Here, we retain the current source line (up to length SLOP)
  2384.          * in the beginning of the buffer that was overallocated above
  2385.          */
  2386.         int offset;
  2387.         int linelen;
  2388.  
  2389.         offset = lexptr - lexeme;
  2390.         for (scan = lexeme; scan > lexptr_begin; scan--)
  2391.             if (*scan == '\n') {
  2392.                 scan++;
  2393.                 break;
  2394.             }
  2395.         linelen = lexptr - scan;
  2396.         if (linelen > SLOP)
  2397.             len = SLOP;
  2398.         thisline = buf + SLOP - linelen;
  2399.         memcpy(thisline, scan, linelen);
  2400.         lexeme = buf + SLOP - offset;
  2401.         lexptr_begin = thisline;
  2402.     }
  2403.     n = read(fd, buf + SLOP, len);
  2404.     if (n == -1)
  2405.         fatal("can't read sourcefile \"%s\" (%s)",
  2406.             source, strerror(errno));
  2407.     if (n == 0) {
  2408.         samefile = 0;
  2409.         nextfile++;
  2410.         return get_src_buf();
  2411.     }
  2412.     lexptr = buf + SLOP;
  2413.     lexend = lexptr + n;
  2414.     return buf;
  2415. }
  2416.  
  2417. #define    tokadd(x) (*token++ = (x), token == tokend ? tokexpand() : token)
  2418.  
  2419. char *
  2420. tokexpand()
  2421. {
  2422.     static int toksize = 60;
  2423.     int tokoffset;
  2424.  
  2425.     tokoffset = token - tokstart;
  2426.     toksize *= 2;
  2427.     if (tokstart)
  2428.         erealloc(tokstart, char *, toksize, "tokexpand");
  2429.     else
  2430.         emalloc(tokstart, char *, toksize, "tokexpand");
  2431.     tokend = tokstart + toksize;
  2432.     token = tokstart + tokoffset;
  2433.     return token;
  2434. }
  2435.  
  2436. #ifdef DEBUG
  2437. char
  2438. nextc() {
  2439.     if (lexptr && lexptr < lexend)
  2440.         return *lexptr++;
  2441.     if (get_src_buf())
  2442.         return *lexptr++;
  2443.     return '\0';
  2444. }
  2445. #else
  2446. #define    nextc()    ((lexptr && lexptr < lexend) ? \
  2447.             *lexptr++ : \
  2448.             (get_src_buf() ? *lexptr++ : '\0') \
  2449.         )
  2450. #endif
  2451. #define pushback() (lexptr && lexptr > lexptr_begin ? lexptr-- : lexptr)
  2452.  
  2453. /*
  2454.  * Read the input and turn it into tokens.
  2455.  */
  2456.  
  2457. static int
  2458. yylex()
  2459. {
  2460.     register int c;
  2461.     int seen_e = 0;        /* These are for numbers */
  2462.     int seen_point = 0;
  2463.     int esc_seen;        /* for literal strings */
  2464.     int low, mid, high;
  2465.     static int did_newline = 0;
  2466.     char *tokkey;
  2467.  
  2468.     if (!nextc())
  2469.         return 0;
  2470.     pushback();
  2471.     lexeme = lexptr;
  2472.     thisline = NULL;
  2473.     if (want_regexp) {
  2474.         int in_brack = 0;
  2475.  
  2476.         want_regexp = 0;
  2477.         token = tokstart;
  2478.         while ((c = nextc()) != 0) {
  2479.             switch (c) {
  2480.             case '[':
  2481.                 in_brack = 1;
  2482.                 break;
  2483.             case ']':
  2484.                 in_brack = 0;
  2485.                 break;
  2486.             case '\\':
  2487.                 if ((c = nextc()) == '\0') {
  2488.                     yyerror("unterminated regexp ends with \\ at end of file");
  2489.                 } else if (c == '\n') {
  2490.                     sourceline++;
  2491.                     continue;
  2492.                 } else
  2493.                     tokadd('\\');
  2494.                 break;
  2495.             case '/':    /* end of the regexp */
  2496.                 if (in_brack)
  2497.                     break;
  2498.  
  2499.                 pushback();
  2500.                 tokadd('\0');
  2501.                 yylval.sval = tokstart;
  2502.                 return REGEXP;
  2503.             case '\n':
  2504.                 pushback();
  2505.                 yyerror("unterminated regexp");
  2506.             case '\0':
  2507.                 yyerror("unterminated regexp at end of file");
  2508.             }
  2509.             tokadd(c);
  2510.         }
  2511.     }
  2512. retry:
  2513.     while ((c = nextc()) == ' ' || c == '\t')
  2514.         ;
  2515.  
  2516.     lexeme = lexptr-1;
  2517.     thisline = NULL;
  2518.     token = tokstart;
  2519.     yylval.nodetypeval = Node_illegal;
  2520.  
  2521.     switch (c) {
  2522.     case 0:
  2523.         return 0;
  2524.  
  2525.     case '\n':
  2526.         sourceline++;
  2527.         return NEWLINE;
  2528.  
  2529.     case '#':        /* it's a comment */
  2530.         while ((c = nextc()) != '\n') {
  2531.             if (c == '\0')
  2532.                 return 0;
  2533.         }
  2534.         sourceline++;
  2535.         return NEWLINE;
  2536.  
  2537.     case '\\':
  2538. #ifdef RELAXED_CONTINUATION
  2539.         if (!strict) {    /* strip trailing white-space and/or comment */
  2540.             while ((c = nextc()) == ' ' || c == '\t') continue;
  2541.             if (c == '#')
  2542.                 while ((c = nextc()) != '\n') if (!c) break;
  2543.             pushback();
  2544.         }
  2545. #endif /*RELAXED_CONTINUATION*/
  2546.         if (nextc() == '\n') {
  2547.             sourceline++;
  2548.             goto retry;
  2549.         } else
  2550.             yyerror("inappropriate use of backslash");
  2551.         break;
  2552.  
  2553.     case '$':
  2554.         want_assign = 1;
  2555.         return '$';
  2556.  
  2557.     case ')':
  2558.     case ']':
  2559.     case '(':    
  2560.     case '[':
  2561.     case ';':
  2562.     case ':':
  2563.     case '?':
  2564.     case '{':
  2565.     case ',':
  2566.         return c;
  2567.  
  2568.     case '*':
  2569.         if ((c = nextc()) == '=') {
  2570.             yylval.nodetypeval = Node_assign_times;
  2571.             return ASSIGNOP;
  2572.         } else if (do_posix) {
  2573.             pushback();
  2574.             return '*';
  2575.         } else if (c == '*') {
  2576.             /* make ** and **= aliases for ^ and ^= */
  2577.             static int did_warn_op = 0, did_warn_assgn = 0;
  2578.  
  2579.             if (nextc() == '=') {
  2580.                 if (do_lint && ! did_warn_assgn) {
  2581.                     did_warn_assgn = 1;
  2582.                     warning("**= is not allowed by POSIX");
  2583.                 }
  2584.                 yylval.nodetypeval = Node_assign_exp;
  2585.                 return ASSIGNOP;
  2586.             } else {
  2587.                 pushback();
  2588.                 if (do_lint && ! did_warn_op) {
  2589.                     did_warn_op = 1;
  2590.                     warning("** is not allowed by POSIX");
  2591.                 }
  2592.                 return '^';
  2593.             }
  2594.         }
  2595.         pushback();
  2596.         return '*';
  2597.  
  2598.     case '/':
  2599.         if (want_assign) {
  2600.             if (nextc() == '=') {
  2601.                 yylval.nodetypeval = Node_assign_quotient;
  2602.                 return ASSIGNOP;
  2603.             }
  2604.             pushback();
  2605.         }
  2606.         return '/';
  2607.  
  2608.     case '%':
  2609.         if (nextc() == '=') {
  2610.             yylval.nodetypeval = Node_assign_mod;
  2611.             return ASSIGNOP;
  2612.         }
  2613.         pushback();
  2614.         return '%';
  2615.  
  2616.     case '^':
  2617.     {
  2618.         static int did_warn_op = 0, did_warn_assgn = 0;
  2619.  
  2620.         if (nextc() == '=') {
  2621.  
  2622.             if (do_lint && ! did_warn_assgn) {
  2623.                 did_warn_assgn = 1;
  2624.                 warning("operator `^=' is not supported in old awk");
  2625.             }
  2626.             yylval.nodetypeval = Node_assign_exp;
  2627.             return ASSIGNOP;
  2628.         }
  2629.         pushback();
  2630.         if (do_lint && ! did_warn_op) {
  2631.             did_warn_op = 1;
  2632.             warning("operator `^' is not supported in old awk");
  2633.         }
  2634.         return '^';
  2635.     }
  2636.  
  2637.     case '+':
  2638.         if ((c = nextc()) == '=') {
  2639.             yylval.nodetypeval = Node_assign_plus;
  2640.             return ASSIGNOP;
  2641.         }
  2642.         if (c == '+')
  2643.             return INCREMENT;
  2644.         pushback();
  2645.         return '+';
  2646.  
  2647.     case '!':
  2648.         if ((c = nextc()) == '=') {
  2649.             yylval.nodetypeval = Node_notequal;
  2650.             return RELOP;
  2651.         }
  2652.         if (c == '~') {
  2653.             yylval.nodetypeval = Node_nomatch;
  2654.             want_assign = 0;
  2655.             return MATCHOP;
  2656.         }
  2657.         pushback();
  2658.         return '!';
  2659.  
  2660.     case '<':
  2661.         if (nextc() == '=') {
  2662.             yylval.nodetypeval = Node_leq;
  2663.             return RELOP;
  2664.         }
  2665.         yylval.nodetypeval = Node_less;
  2666.         pushback();
  2667.         return '<';
  2668.  
  2669.     case '=':
  2670.         if (nextc() == '=') {
  2671.             yylval.nodetypeval = Node_equal;
  2672.             return RELOP;
  2673.         }
  2674.         yylval.nodetypeval = Node_assign;
  2675.         pushback();
  2676.         return ASSIGNOP;
  2677.  
  2678.     case '>':
  2679.         if ((c = nextc()) == '=') {
  2680.             yylval.nodetypeval = Node_geq;
  2681.             return RELOP;
  2682.         } else if (c == '>') {
  2683.             yylval.nodetypeval = Node_redirect_append;
  2684.             return APPEND_OP;
  2685.         }
  2686.         yylval.nodetypeval = Node_greater;
  2687.         pushback();
  2688.         return '>';
  2689.  
  2690.     case '~':
  2691.         yylval.nodetypeval = Node_match;
  2692.         want_assign = 0;
  2693.         return MATCHOP;
  2694.  
  2695.     case '}':
  2696.         /*
  2697.          * Added did newline stuff.  Easier than
  2698.          * hacking the grammar
  2699.          */
  2700.         if (did_newline) {
  2701.             did_newline = 0;
  2702.             return c;
  2703.         }
  2704.         did_newline++;
  2705.         --lexptr;    /* pick up } next time */
  2706.         return NEWLINE;
  2707.  
  2708.     case '"':
  2709.         esc_seen = 0;
  2710.         while ((c = nextc()) != '"') {
  2711.             if (c == '\n') {
  2712.                 pushback();
  2713.                 yyerror("unterminated string");
  2714.             }
  2715.             if (c == '\\') {
  2716.                 c = nextc();
  2717.                 if (c == '\n') {
  2718.                     sourceline++;
  2719.                     continue;
  2720.                 }
  2721.                 esc_seen = 1;
  2722.                 tokadd('\\');
  2723.             }
  2724.             if (c == '\0') {
  2725.                 pushback();
  2726.                 yyerror("unterminated string");
  2727.             }
  2728.             tokadd(c);
  2729.         }
  2730.         yylval.nodeval = make_str_node(tokstart,
  2731.                     token - tokstart, esc_seen ? SCAN : 0);
  2732.         yylval.nodeval->flags |= PERM;
  2733.         return YSTRING;
  2734.  
  2735.     case '-':
  2736.         if ((c = nextc()) == '=') {
  2737.             yylval.nodetypeval = Node_assign_minus;
  2738.             return ASSIGNOP;
  2739.         }
  2740.         if (c == '-')
  2741.             return DECREMENT;
  2742.         pushback();
  2743.         return '-';
  2744.  
  2745.     case '.':
  2746.         c = nextc();
  2747.         pushback();
  2748.         if (!isdigit(c))
  2749.             return '.';
  2750.         else
  2751.             c = '.';    /* FALL THROUGH */
  2752.     case '0':
  2753.     case '1':
  2754.     case '2':
  2755.     case '3':
  2756.     case '4':
  2757.     case '5':
  2758.     case '6':
  2759.     case '7':
  2760.     case '8':
  2761.     case '9':
  2762.         /* It's a number */
  2763.         for (;;) {
  2764.             int gotnumber = 0;
  2765.  
  2766.             tokadd(c);
  2767.             switch (c) {
  2768.             case '.':
  2769.                 if (seen_point) {
  2770.                     gotnumber++;
  2771.                     break;
  2772.                 }
  2773.                 ++seen_point;
  2774.                 break;
  2775.             case 'e':
  2776.             case 'E':
  2777.                 if (seen_e) {
  2778.                     gotnumber++;
  2779.                     break;
  2780.                 }
  2781.                 ++seen_e;
  2782.                 if ((c = nextc()) == '-' || c == '+')
  2783.                     tokadd(c);
  2784.                 else
  2785.                     pushback();
  2786.                 break;
  2787.             case '0':
  2788.             case '1':
  2789.             case '2':
  2790.             case '3':
  2791.             case '4':
  2792.             case '5':
  2793.             case '6':
  2794.             case '7':
  2795.             case '8':
  2796.             case '9':
  2797.                 break;
  2798.             default:
  2799.                 gotnumber++;
  2800.             }
  2801.             if (gotnumber)
  2802.                 break;
  2803.             c = nextc();
  2804.         }
  2805.         pushback();
  2806.         yylval.nodeval = make_number(atof(tokstart));
  2807.         yylval.nodeval->flags |= PERM;
  2808.         return YNUMBER;
  2809.  
  2810.     case '&':
  2811.         if ((c = nextc()) == '&') {
  2812.             yylval.nodetypeval = Node_and;
  2813.             for (;;) {
  2814.                 c = nextc();
  2815.                 if (c == '\0')
  2816.                     break;
  2817.                 if (c == '#') {
  2818.                     while ((c = nextc()) != '\n' && c != '\0')
  2819.                         ;
  2820.                     if (c == '\0')
  2821.                         break;
  2822.                 }
  2823.                 if (c == '\n')
  2824.                     sourceline++;
  2825.                 if (! isspace(c)) {
  2826.                     pushback();
  2827.                     break;
  2828.                 }
  2829.             }
  2830.             want_assign = 0;
  2831.             return LEX_AND;
  2832.         }
  2833.         pushback();
  2834.         return '&';
  2835.  
  2836.     case '|':
  2837.         if ((c = nextc()) == '|') {
  2838.             yylval.nodetypeval = Node_or;
  2839.             for (;;) {
  2840.                 c = nextc();
  2841.                 if (c == '\0')
  2842.                     break;
  2843.                 if (c == '#') {
  2844.                     while ((c = nextc()) != '\n' && c != '\0')
  2845.                         ;
  2846.                     if (c == '\0')
  2847.                         break;
  2848.                 }
  2849.                 if (c == '\n')
  2850.                     sourceline++;
  2851.                 if (! isspace(c)) {
  2852.                     pushback();
  2853.                     break;
  2854.                 }
  2855.             }
  2856.             want_assign = 0;
  2857.             return LEX_OR;
  2858.         }
  2859.         pushback();
  2860.         return '|';
  2861.     }
  2862.  
  2863.     if (c != '_' && ! isalpha(c))
  2864.         yyerror("Invalid char '%c' in expression\n", c);
  2865.  
  2866.     /* it's some type of name-type-thing.  Find its length */
  2867.     token = tokstart;
  2868.     while (is_identchar(c)) {
  2869.         tokadd(c);
  2870.         c = nextc();
  2871.     }
  2872.     tokadd('\0');
  2873.     emalloc(tokkey, char *, token - tokstart, "yylex");
  2874.     memcpy(tokkey, tokstart, token - tokstart);
  2875.     pushback();
  2876.  
  2877.     /* See if it is a special token.  */
  2878.     low = 0;
  2879.     high = (sizeof (tokentab) / sizeof (tokentab[0])) - 1;
  2880.     while (low <= high) {
  2881.         int i/* , c */;
  2882.  
  2883.         mid = (low + high) / 2;
  2884.         c = *tokstart - tokentab[mid].operator[0];
  2885.         i = c ? c : strcmp (tokstart, tokentab[mid].operator);
  2886.  
  2887.         if (i < 0) {        /* token < mid */
  2888.             high = mid - 1;
  2889.         } else if (i > 0) {    /* token > mid */
  2890.             low = mid + 1;
  2891.         } else {
  2892.             if (do_lint) {
  2893.                 if (tokentab[mid].flags & GAWKX)
  2894.                     warning("%s() is a gawk extension",
  2895.                         tokentab[mid].operator);
  2896.                 if (tokentab[mid].flags & NOT_POSIX)
  2897.                     warning("POSIX does not allow %s",
  2898.                         tokentab[mid].operator);
  2899.                 if (tokentab[mid].flags & NOT_OLD)
  2900.                     warning("%s is not supported in old awk",
  2901.                         tokentab[mid].operator);
  2902.             }
  2903.             if ((strict && (tokentab[mid].flags & GAWKX))
  2904.                 || (do_posix && (tokentab[mid].flags & NOT_POSIX)))
  2905.                 break;
  2906.             if (tokentab[mid].class == LEX_BUILTIN
  2907.                 || tokentab[mid].class == LEX_LENGTH
  2908.                )
  2909.                 yylval.lval = mid;
  2910.             else
  2911.                 yylval.nodetypeval = tokentab[mid].value;
  2912.  
  2913.             return tokentab[mid].class;
  2914.         }
  2915.     }
  2916.  
  2917.     yylval.sval = tokkey;
  2918.     if (*lexptr == '(')
  2919.         return FUNC_CALL;
  2920.     else {
  2921.         want_assign = 1;
  2922.         return NAME;
  2923.     }
  2924. }
  2925.  
  2926. static NODE *
  2927. node_common(op)
  2928. NODETYPE op;
  2929. {
  2930.     register NODE *r;
  2931.  
  2932.     getnode(r);
  2933.     r->type = op;
  2934.     r->flags = MALLOC;
  2935.     /* if lookahead is NL, lineno is 1 too high */
  2936.     if (lexeme && *lexeme == '\n')
  2937.         r->source_line = sourceline - 1;
  2938.     else
  2939.         r->source_line = sourceline;
  2940.     r->source_file = source;
  2941.     return r;
  2942. }
  2943.  
  2944. /*
  2945.  * This allocates a node with defined lnode and rnode. 
  2946.  */
  2947. NODE *
  2948. node(left, op, right)
  2949. NODE *left, *right;
  2950. NODETYPE op;
  2951. {
  2952.     register NODE *r;
  2953.  
  2954.     r = node_common(op);
  2955.     r->lnode = left;
  2956.     r->rnode = right;
  2957.     return r;
  2958. }
  2959.  
  2960. /*
  2961.  * This allocates a node with defined subnode and proc for builtin functions
  2962.  * Checks for arg. count and supplies defaults where possible.
  2963.  */
  2964. static NODE *
  2965. snode(subn, op, idx)
  2966. NODETYPE op;
  2967. int idx;
  2968. NODE *subn;
  2969. {
  2970.     register NODE *r;
  2971.     register NODE *n;
  2972.     int nexp = 0;
  2973.     int args_allowed;
  2974.  
  2975.     r = node_common(op);
  2976.  
  2977.     /* traverse expression list to see how many args. given */
  2978.     for (n= subn; n; n= n->rnode) {
  2979.         nexp++;
  2980.         if (nexp > 3)
  2981.             break;
  2982.     }
  2983.  
  2984.     /* check against how many args. are allowed for this builtin */
  2985.     args_allowed = tokentab[idx].flags & ARGS;
  2986.     if (args_allowed && !(args_allowed & A(nexp)))
  2987.         fatal("%s() cannot have %d argument%c",
  2988.             tokentab[idx].operator, nexp, nexp == 1 ? ' ' : 's');
  2989.  
  2990.     r->proc = tokentab[idx].ptr;
  2991.  
  2992.     /* special case processing for a few builtins */
  2993.     if (nexp == 0 && r->proc == do_length) {
  2994.         subn = node(node(make_number(0.0),Node_field_spec,(NODE *)NULL),
  2995.                     Node_expression_list,
  2996.                 (NODE *) NULL);
  2997.     } else if (r->proc == do_match) {
  2998.         if (subn->rnode->lnode->type != Node_regex)
  2999.             subn->rnode->lnode = mk_rexp(subn->rnode->lnode);
  3000.     } else if (r->proc == do_sub || r->proc == do_gsub) {
  3001.         if (subn->lnode->type != Node_regex)
  3002.             subn->lnode = mk_rexp(subn->lnode);
  3003.         if (nexp == 2)
  3004.             append_right(subn, node(node(make_number(0.0),
  3005.                              Node_field_spec,
  3006.                              (NODE *) NULL),
  3007.                             Node_expression_list,
  3008.                         (NODE *) NULL));
  3009.         else if (do_lint && subn->rnode->rnode->lnode->type == Node_val)
  3010.             warning("string literal as last arg of substitute");
  3011.     } else if (r->proc == do_split) {
  3012.         if (nexp == 2)
  3013.             append_right(subn,
  3014.                 node(FS_node, Node_expression_list, (NODE *) NULL));
  3015.         n = subn->rnode->rnode->lnode;
  3016.         if (n->type != Node_regex)
  3017.             subn->rnode->rnode->lnode = mk_rexp(n);
  3018.         if (nexp == 2)
  3019.             subn->rnode->rnode->lnode->re_flags |= FS_DFLT;
  3020.     }
  3021.  
  3022.     r->subnode = subn;
  3023.     return r;
  3024. }
  3025.  
  3026. /*
  3027.  * This allocates a Node_line_range node with defined condpair and
  3028.  * zeroes the trigger word to avoid the temptation of assuming that calling
  3029.  * 'node( foo, Node_line_range, 0)' will properly initialize 'triggered'. 
  3030.  */
  3031. /* Otherwise like node() */
  3032. static NODE *
  3033. mkrangenode(cpair)
  3034. NODE *cpair;
  3035. {
  3036.     register NODE *r;
  3037.  
  3038.     getnode(r);
  3039.     r->type = Node_line_range;
  3040.     r->condpair = cpair;
  3041.     r->triggered = 0;
  3042.     return r;
  3043. }
  3044.  
  3045. /* Build a for loop */
  3046. static NODE *
  3047. make_for_loop(init, cond, incr)
  3048. NODE *init, *cond, *incr;
  3049. {
  3050.     register FOR_LOOP_HEADER *r;
  3051.     NODE *n;
  3052.  
  3053.     emalloc(r, FOR_LOOP_HEADER *, sizeof(FOR_LOOP_HEADER), "make_for_loop");
  3054.     getnode(n);
  3055.     n->type = Node_illegal;
  3056.     r->init = init;
  3057.     r->cond = cond;
  3058.     r->incr = incr;
  3059.     n->sub.nodep.r.hd = r;
  3060.     return n;
  3061. }
  3062.  
  3063. /*
  3064.  * Install a name in the symbol table, even if it is already there.
  3065.  * Caller must check against redefinition if that is desired. 
  3066.  */
  3067. NODE *
  3068. install(name, value)
  3069. char *name;
  3070. NODE *value;
  3071. {
  3072.     register NODE *hp;
  3073.     register int len, bucket;
  3074.  
  3075.     len = strlen(name);
  3076.     bucket = hash(name, len);
  3077.     getnode(hp);
  3078.     hp->type = Node_hashnode;
  3079.     hp->hnext = variables[bucket];
  3080.     variables[bucket] = hp;
  3081.     hp->hlength = len;
  3082.     hp->hvalue = value;
  3083.     hp->hname = name;
  3084.     return hp->hvalue;
  3085. }
  3086.  
  3087. /* find the most recent hash node for name installed by install */
  3088. NODE *
  3089. lookup(name)
  3090. char *name;
  3091. {
  3092.     register NODE *bucket;
  3093.     register int len;
  3094.  
  3095.     len = strlen(name);
  3096.     bucket = variables[hash(name, len)];
  3097.     while (bucket) {
  3098.         if (bucket->hlength == len && STREQN(bucket->hname, name, len))
  3099.             return bucket->hvalue;
  3100.         bucket = bucket->hnext;
  3101.     }
  3102.     return NULL;
  3103. }
  3104.  
  3105. /*
  3106.  * Add new to the rightmost branch of LIST.  This uses n^2 time, so we make
  3107.  * a simple attempt at optimizing it.
  3108.  */
  3109. static NODE *
  3110. append_right(list, new)
  3111. NODE *list, *new;
  3112. {
  3113.     register NODE *oldlist;
  3114.     static NODE *savefront = NULL, *savetail = NULL;
  3115.  
  3116.     oldlist = list;
  3117.     if (savefront == oldlist) {
  3118.         savetail = savetail->rnode = new;
  3119.         return oldlist;
  3120.     } else
  3121.         savefront = oldlist;
  3122.     while (list->rnode != NULL)
  3123.         list = list->rnode;
  3124.     savetail = list->rnode = new;
  3125.     return oldlist;
  3126. }
  3127.  
  3128. /*
  3129.  * check if name is already installed;  if so, it had better have Null value,
  3130.  * in which case def is added as the value. Otherwise, install name with def
  3131.  * as value. 
  3132.  */
  3133. static void
  3134. func_install(params, def)
  3135. NODE *params;
  3136. NODE *def;
  3137. {
  3138.     NODE *r;
  3139.  
  3140.     pop_params(params->rnode);
  3141.     pop_var(params, 0);
  3142.     r = lookup(params->param);
  3143.     if (r != NULL) {
  3144.         fatal("function name `%s' previously defined", params->param);
  3145.     } else
  3146.         (void) install(params->param, node(params, Node_func, def));
  3147. }
  3148.  
  3149. static void
  3150. pop_var(np, freeit)
  3151. NODE *np;
  3152. int freeit;
  3153. {
  3154.     register NODE *bucket, **save;
  3155.     register int len;
  3156.     char *name;
  3157.  
  3158.     name = np->param;
  3159.     len = strlen(name);
  3160.     save = &(variables[hash(name, len)]);
  3161.     for (bucket = *save; bucket; bucket = bucket->hnext) {
  3162.         if (len == bucket->hlength && STREQN(bucket->hname, name, len)) {
  3163.             *save = bucket->hnext;
  3164.             freenode(bucket);
  3165.             if (freeit)
  3166.                 free(np->param);
  3167.             return;
  3168.         }
  3169.         save = &(bucket->hnext);
  3170.     }
  3171. }
  3172.  
  3173. static void
  3174. pop_params(params)
  3175. NODE *params;
  3176. {
  3177.     register NODE *np;
  3178.  
  3179.     for (np = params; np != NULL; np = np->rnode)
  3180.         pop_var(np, 1);
  3181. }
  3182.  
  3183. static NODE *
  3184. make_param(name)
  3185. char *name;
  3186. {
  3187.     NODE *r;
  3188.  
  3189.     getnode(r);
  3190.     r->type = Node_param_list;
  3191.     r->rnode = NULL;
  3192.     r->param = name;
  3193.     r->param_cnt = param_counter++;
  3194.     return (install(name, r));
  3195. }
  3196.  
  3197. /* Name points to a variable name.  Make sure its in the symbol table */
  3198. NODE *
  3199. variable(name, can_free)
  3200. char *name;
  3201. int can_free;
  3202. {
  3203.     register NODE *r;
  3204.     static int env_loaded = 0;
  3205.  
  3206.     if (!env_loaded && STREQ(name, "ENVIRON")) {
  3207.         load_environ();
  3208.         env_loaded = 1;
  3209.     }
  3210.     if ((r = lookup(name)) == NULL)
  3211.         r = install(name, node(Nnull_string, Node_var, (NODE *) NULL));
  3212.     else if (can_free)
  3213.         free(name);
  3214.     return r;
  3215. }
  3216.  
  3217. static NODE *
  3218. mk_rexp(exp)
  3219. NODE *exp;
  3220. {
  3221.     if (exp->type == Node_regex)
  3222.         return exp;
  3223.     else {
  3224.         NODE *n;
  3225.  
  3226.         getnode(n);
  3227.         n->type = Node_regex;
  3228.         n->re_exp = exp;
  3229.         n->re_text = NULL;
  3230.         n->re_reg = NULL;
  3231.         n->re_flags = 0;
  3232.         n->re_cnt = 1;
  3233.         return n;
  3234.     }
  3235. }
  3236.